I have the following code which runs fine on all operating systems (32 & 64 bit) except for Windows 2008 R2 (SP0 & SP1)
fSvc := OpenServiceW(fSvcMgr, pwidechar(Service_name),SERVICE_ALL_ACCESS);
if fSvc = 0 then
begin
fSvc := CreateServiceW(fSvcMgr,
pwidechar(Service_name),
pwidechar(Service_name),
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_IGNORE,
pwidechar(fServiceName), nil, nil, nil, nil, nil);
if fSvc = 0 then
begin
iserror := true;
RaiseLastWin32Error;
end;
end;
**This happens when connecting to a remote 32 bit machine:**
While debugging delphi crashes on the CreateserviceW line with message 'Application-defined exception (code 0x000006d1) at ... process stopped. try/except around the createserviceW doesn't make any difference.
**When connecting to a remote 64 bit machine everything works fine!**