المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Access Denied returned from CreateService



C++ Programming
05-06-2009, 03:50 PM
Hello All,

When I am executing the following code

SC_HANDLE schSCManager, schService;
TCHAR szPath[MAX_PATH];

GetModuleFileName(NULL, szPath, MAX_PATH);
schSCManager = OpenSCManager(NULL, NULL ,SC_MANAGER_ALL_ACCESS);

if ( schSCManager == NULL )
return false;

schService = CreateService(schSCManager, USER_SERVICE_NAME, USER_SERVICE_NAME,
SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS,SERVICE_DEMAND_START,SERVICE_ERROR_NORMAL, szPath, NULL, NULL, NULL, NULL, NULL);

The CreateService() is not returning a proper handle. When I used GetLastError(), its throwing a ERROR_ACCESS_DENIED error. Please help in solving this issue.

Thanks in advance,
Neelesh K J Jain.