Re: Why I can not use NetQueryDisplayInformation in a service?
what should I do?
change this?
CreateService(
schSCManager, // SCManager database
lpszDisplayName, // name of service
lpszDisplayName, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_DEMAND_START, // start type
SERVICE_ERROR_NORMAL, // error control type
lpszBinaryPathName, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // no dependencies
NULL, // LocalSystem account
NULL);
or change
{
ServiceStatus.dwServiceType =
SERVICE_WIN32;
ServiceStatus.dwCurrentState =
SERVICE_START_PENDING;
ServiceStatus.dwControlsAccepted =
SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_NETBINDCHANGE;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
}
I am really puzzled about the privilege.(SERVICE_ALL_ACCESS do not have the
privilege?)
In fact I even can not start my service when using CreateService.
I only want the NetQueryDisplayInformation working .
"Bruno van Dooren [MVP VC++]" <bruno_nos_pam_van_dooren@hotmail.com> ????????????:eq6ad6QSHHA.3440@TK2MSFTNGP03.phx.gbl...
res = NetQueryDisplayInformation(szServer, 1, i, 1000, 0xFFFFFFFF,
&dwRec, (void **)&pBuff);
it's OK in exe
but failed in a service
return ERROR_ACCESS_DENIED,
why?
Because your service is running with different credentials.
Probably with LOCAL_SYSTEM credentials. This means it cannot access
network resources.
Try to change the logon configuration for your service to a named user
account that has access to szServer. That should help.
--
Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"