I'm calling CoInitialize in the project source of the service application.
This is my code (project source of the service application):
program Serv_ADO;
uses
SvcMgr,
Serv_ADO1 in 'Serv_ADO1.pas' {Service1: TService},
Dialogs, Sysutils;
{$R *.RES}
function CoInitialize(p: Pointer): HRESULT; external 'ole32.dll';
procedure CoUninitialize; external 'ole32.dll';
const
S_OK = 0;
S_FALSE = 1;
E_OUTOFMEMORY = $8007000E;
E_INVALIDARG = $80070057;
E_UNEXPECTED = $8000FFFF;
var n : Integer;
begin
n := CoInitialize(nil);
if n=S_OK then
begin
Application.Initialize;
Application.CreateForm(TService1, Service1);
Application.Run;
end;
CoUninitialize;
end.
The Win32 Programmer's Reference says that the argument of CoInitialize must
be NULL.
I tried calling it in the OnServiceStart event but it gave the same result.
Where should you call CoInitialize?
Does anyone know why this doesn't work? What am I doing wrong?
(In the Win32 Programmer's Reference help file which comes with Delphi, the
link from the index entry for CoInitialize points to the wrong page. I'm
using an earlier copy).