using createservice

Hi experts,
Has anyone got a code example of how to use CREATESERVICE. I'm getting stuck with the lpDependencies (what the heck do I put in it). :(
Thanks,
DJ
DickJonesOCPAsked:
Who is Participating?
 
mokuleConnect With a Mentor Commented:
example from MSDN in C but its clear enough I think

BOOL CreateSampleService()
{
    LPCTSTR lpszBinaryPathName =
        "%SystemRoot%\\system\\testserv.exe";
 
    schService = CreateService(
        schSCManager,              // SCManager database
        "Sample_Srv",              // 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)
    {
        printf("CreateService failed.\n");
        return FALSE;
    }
    else
    {
        CloseServiceHandle(schService);
        return TRUE;
    }
}

0
 
mokuleCommented:
Most probably You should  place there nil meaning that Your service doesn't require any service started before by the system.
0
 
DickJonesOCPAuthor Commented:
mokule,
dependencies doesn't like the value NULL or nil or anything else I've tried. It comes up with a message 'incompatible types STRING and PDWORD' ??

help !
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mokuleCommented:
place empty string
0
 
DickJonesOCPAuthor Commented:
tried that, same message :(
and an emtpy pdword
0
 
DickJonesOCPAuthor Commented:
Aha worked with a 0, gave you the points coz u came up with a descriptor (even though I had it anyway) but thanks for your help,
All the best,
DJ
0
All Courses

From novice to tech pro — start learning today.