Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Engine Init - CoInitialize not called  (Read 3604 times)
Skellods
Community Member
*
Posts: 10


WWW
« on: December 22, 2010, 06:14:06 PM »

I use Delphi 2010 and Windows 7 32 bit.
Until now I haven't had any problems. I didn't change my code. I initialize the Engine with "TV := CoTVEngine.Create;"
Suddenly, there is an error. The debugger tells me
"Erste Gelegenheit für Exception bei $75BE9617. Exception-Klasse EOleSysError mit Meldung 'CoInitialize wurde nicht aufgerufen'. Prozess Skellods.exe (8304)" (sry, I'm German Wink )
When I look where the error is to be found the debugger marks the following red (it's in an Engine Header):
"class function CoTVEngine.Create: ITVEngine;
begin
  Result := CreateComObject(CLASS_TVEngine) as ITVEngine;   <-this is red
end;"
I could fix it on my Computer with a dialog before the initialization. But it won't work for others. The DLL is registered correctly!
« Last Edit: December 23, 2010, 04:19:52 AM by Skellods » Logged

AriusEso
Customers
Community Member
*****
Posts: 940

Esoteric


« Reply #1 on: December 23, 2010, 06:43:22 AM »

Hmm, can you show your code please?

Also, do you generate the header yourself?
Logged

-...-

Skellods
Community Member
*
Posts: 10


WWW
« Reply #2 on: December 23, 2010, 12:57:19 PM »

1st my code. I really don't know why this is happening. Everything was fine until I thought about preventing my mesh from leaving the terrain (I controle a mesh (box) that moves on an empty terrain). So it has absolutely nothing to do with the initialization. I didn't change anything until the mainloop.
2nd the headers. No, I do not generate them. I only imported the DLL (ActiveX). So everything is autogenerated. And as I said: everything already worked. COM/OLE Class is registered!

Code you could need (this is a DLL!):

Code:
procedure Initcomps;
begin
  // Init components
  // if I put a "Showmessage('123');" here it works on my computer others will also see this dialog, but then fail
  ShowCursor(false);
  TV := CoTVEngine.Create; // yeeees, I call CoTVEngine here. So what is the problem?
  Scene := CoTVScene.Create;
  graphics := CoTVGraphicEffect.Create;
  _id := CoTVDeviceInfo.Create;
  Globals := CoTVGlobals.Create;
  _Text := CoTVScreen2DText.Create;
  Input := CoTVInputEngine.Create;
  intobj := CoTVInternalObjects.Create;
  cam := CoTVCamera.Create;
  atmo := CoTVAtmosphere.Create;
  tex := CoTVTextureFactory.Create;
  icam := CoTVCameraFactory.Create;
  light := CoTVLightEngine.Create;
  pack := CoTVPackage.Create;
  _2D := CoTVScreen2DImmediate.Create;
  physic := CoTVPhysics.Create;
  land := Scene.CreateLandscape('testland');
end;

procedure init;
begin
  Randomize;
  // Load IniFile
  ini:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'options.ini');
  readini; // this is for loading game options like resolution etc.
  // Engine init
  Initcomps;
  // some other things are initialized....
end;

procedure thisgame(const PW: PChar);
begin
  // SOME CODE HERE: serialnumber-system - works - so everything until here is ok
  init;
  _2D.Load_Background(pack.GetFile('loading.jpg',graphicpak),False);
  // main loop
  while _end=False do
  begin
    if TV.IsFullscreen=False then if frm.Visible=False then _end:=True;
    if(PeekMessage( Msg, 0, WM_NULL, WM_NULL, PM_REMOVE ) ) then
      begin
        TranslateMessage( Msg );
        DispatchMessage( Msg );
      end
    else
    begin
      if gameinited=False then
        Main;
      if gameinited=True then
        begin
          if _loading=False then
            Maingame;
          if _loading then
            initgame;
        end;
    end;
  end;
  if smenu=True then
    dimout
  else
    dimoutgame;
  Endscreen;
  Sleep(1000);
  ini.Free;
  TV:=nil;
  TerminateProcess(GetCurrentProcess,0);
end;

exports thisgame;
« Last Edit: December 23, 2010, 01:08:55 PM by Skellods » Logged

Skellods
Community Member
*
Posts: 10


WWW
« Reply #3 on: December 25, 2010, 11:31:33 AM »

OK, I found a solution. This really is a bug!!!
You have to add
Code:
CoInitialize(nil);
before the first initialization of the components (uses ActiveX)!!! Pls add this to the initialization of the Engine in the autogenerated header.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks