COM error when using uROComInit on a new program

Hi guys,

Try this out, create a new VCL Application (i’m using Seattle, no Update 1).

On the form simply drop a TWebBrowser component. Now on the Project1.pas file add the uROComInit and run the program. I’m currently getting the error “could not obtain ole control window handle”.

program Project1;

uses
  uROComInit,
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

If you remove the uROComInit line it works. I’ll test with Seattle Update 1 and report back. Using latest non beta release of Delphi DA Server.

1 Like

Ok, confirmed. Seattle with Update 1 has the same effect.

Most of the RO Wizards (client and server side) will put the unit at the beginning to have the CoInitialize call, so most people will experience this issue if they use TWebBrowesr.

You can use

uROInitializedThread.ROInitializeThreads := True;

in .dpr.

this is workaround for cases when uROCOMInit unit can’t be used

1 Like

Hello,

Please pardon my ignorance as I am very rusty with Delphi. Did you mean “.drp” or “.dpr” for Delphi Project file?

If I understand you correctly the uROCOMInit reference must be removed and the line of code added. At what point should I add this line? And what reference do I need to add as the compiler complains that uROInitializedThread is an undefined symbol.

program Popcorn;

{#ROGEN:VPIServer.RODL} // RemObjects SDK: Careful, do not remove!

uses
  // uROComInit,
  FMX.Forms,
  fServerForm in 'fServerForm.pas' {MainForm},
  LoginService_Impl in 'LoginService_Impl.pas' {LoginService: TSimpleLoginService},
  DataService_Impl in 'DataService_Impl.pas' {DataService: TDARemoteService},
  fServerDataModule in 'fServerDataModule.pas' {ServerDataModule: TDataModule},
  VPI_Intf in 'VPI_Intf.pas',
  VPI_Invk in 'VPI_Invk.pas';

{$R *.res}
{$R RODLFile.res}

begin
  uROInitializedThread.ROInitializeThreads := True;

  Application.Initialize;
  Application.CreateForm(TServerDataModule, ServerDataModule);
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end.

uROInitializedThread.pas is unit that contains ROInitializeThreads variable so you need to add uROInitializedThread instead of uROComInit

1 Like