Archived from groups: microsoft.public.vc.language,microsoft.public.vc.mfc,microsoft.public.windowsxp.security_admin (
More info?)
Hi Thanks for your info. Below is the code I tried. For easier reading, I
have remved error checkings. The CreateService is successful, the service
shows up in the Control Panel - Services program and can be started there
too. But the StartService (hService) did not work. The status shown in the
Control Panel - Services program is always "Starting" and just hang there
and never finish. As you can see, I did use the SERVICE_ALL_ACCESS in
CreateService.
Please let me know if you can see something wrong here.
Thanks!
Polaris
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
SC_HANDLE hscm = OpenSCManager (NULL, SERVICES_ACTIVE_DATABASE,
SC_MANAGER_CREATE_SERVICE);
if (hscm)
{
SC_HANDLE hService = CreateService (hscm, g_szServiceName,
g_szDisplayName, SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS |
SERVICE_INTERACTIVE_PROCESS,
SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
path,
0, 0, 0, 0, 0);
StartService (hService);
if (hService)
CloseServiceHandle (hService);
CloseServiceHandle (hscm);
}
"thatsalok" <thatsalok@NO_gmail.com_I_DONT_NEED_SPAM> wrote in message
news:ehfDPrCNFHA.1436@TK2MSFTNGP10.phx.gbl...
> Could you post little Code snippet ,describing extactly how are using
> StartService(...) api?
> Have you tried taking valid HANDLE form OpenSCManager(...) with all
> access.
>
>
> --
>
> With Regards
> Alok Gupta
> Visit me at
http://alok.bizhat.com
>
> "I Believe this will Help"
>
>
> "Polaris" <etpolaris@hotmail.com> wrote in message
> news:uRAwTcCNFHA.2252@TK2MSFTNGP15.phx.gbl...
>> Hi:
>>
>> I wrote a service program on XP. The service can be started manually in
> the
>> Control Panel - Service program, but I could not start it
> programmatically;
>> call to StartService() returns Error message saying could not connect to
> the
>> Service Control Manager.
>>
>> Appreciate any hits from you!
>>
>> Thanks in Advance
>> Polaris
>>
>>
>
>