Click to See Complete Forum and Search --> : why service is not creating.....


sg_madhu
July 23rd, 2003, 10:44 PM
SC_HANDLE schSCManager;
schSCManager = OpenSCManager(
NULL, // local machine
NULL, // ServicesActive database
SC_MANAGER_ALL_ACCESS); // full access rights

if (schSCManager == NULL)
AfxMessageBox("Open Service Control Manager Failed...");

LPCTSTR lpszBinaryPathName ="C:\\PROGRA~1\\Grisoft\\AVG6\\avgserv.exe" ;
LPCTSTR lpszDisplayName="AVG6 Service";

SC_HANDLE schService = CreateService(
schSCManager, // SCManager database
"AVG6 Service", // 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); // no password

if (schService == NULL)
AfxMessageBox("CreateService Failed");

if (schService != NULL)
AfxMessageBox("CreateService SUCCESS.\n");

SERVICE_STATUS ssStatus;
DWORD dwOldCheckPoint;
DWORD dwStartTickCount;
DWORD dwWaitTime;
DWORD dwStatus;

schService = OpenService(
schSCManager, // SCM database
"AVG6 Service", // service name
SERVICE_ALL_ACCESS);

if (schService == NULL)
{
AfxMessageBox("OpenService Failed");
}

if (!StartService(
schService, // handle to service
0, // number of arguments
NULL) ) // no arguments
{
AfxMessageBox("StartService");
}
else
{
AfxMessageBox("Service start pending.\n");
}



if any body knows what is wrong in the above code ...........