Thread: SC_HANDLE Helppp!

  1. #1
    Registered User
    Join Date
    Sep 2002

    SC_HANDLE Helppp!

    Can anyone tell me why the following piece of code gives an error of undeclared identifier for the SC_HANDLE declarations?

    unsigned char StartPortTalkDriver(void)
        SC_HANDLE  SchSCManager;
        SC_HANDLE  schService;
        BOOL       ret;
        DWORD      err;
        /* Open Handle to Service Control Manager */
        SchSCManager = OpenSCManager (NULL,                        /* machine (NULL == local) */
                                      NULL,                        /* database (NULL == default) */
                                      SC_MANAGER_ALL_ACCESS);      /* access required */
        if (SchSCManager == NULL)
          if (GetLastError() == ERROR_ACCESS_DENIED) {
             /* We do not have enough rights to open the SCM, therefore we must */
             /* be a poor user with only user rights. */
             printf("PortTalk: You do not have rights to access the Service Control Manager and\n");
             printf("PortTalk: the PortTalk driver is not installed or started. Please ask \n");
             printf("PortTalk: your administrator to install the driver on your behalf.\n");
        do {
             /* Open a Handle to the PortTalk Service Database */
             schService = OpenService(SchSCManager,         /* handle to service control manager database */
                                      "PortTalk",           /* pointer to name of service to start */
                                      SERVICE_ALL_ACCESS);  /* type of access to service */
             if (schService == NULL)
                switch (GetLastError()){
                    case ERROR_ACCESS_DENIED:
                            printf("PortTalk: You do not have rights to the PortTalk service database\n");
                    case ERROR_INVALID_NAME:
                            printf("PortTalk: The specified service name is invalid.\n");
                    case ERROR_SERVICE_DOES_NOT_EXIST:
                            printf("PortTalk: The PortTalk driver does not exist. Installing driver.\n");
                            printf("PortTalk: This can take up to 30 seconds on some machines . .\n");
             } while (schService == NULL);
        /* Start the PortTalk Driver. Errors will occur here if PortTalk.SYS file doesn't exist */
        ret = StartService (schService,    /* service identifier */
                            0,             /* number of arguments */
                            NULL);         /* pointer to arguments */
        if (ret) printf("PortTalk: The PortTalk driver has been successfully started.\n");
        else {
            err = GetLastError();
            if (err == ERROR_SERVICE_ALREADY_RUNNING)
              printf("PortTalk: The PortTalk driver is already running.\n");
            else {
              printf("PortTalk: Unknown error while starting PortTalk driver service.\n");
              printf("PortTalk: Does PortTalk.SYS exist in your \\System32\\Drivers Directory?\n");
        /* Close handle to Service Control Manager */
        CloseServiceHandle (schService);
    many thanks

    Code tags added by Kermi3

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    In the furture please use Code Tags.

    Information on code tags may be found at:

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Did you #include whatever file contains that definition?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin.get() Helppp!!!
    By yukapuka in forum C++ Programming
    Replies: 6
    Last Post: 05-03-2008, 11:57 AM
  2. helppp in bank databse
    By neha007 in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2007, 09:43 AM
  3. Helppp
    By GQgirl in forum C Programming
    Replies: 6
    Last Post: 11-23-2006, 05:03 PM
  4. Modem programming helppp amateur!!
    By Siagal in forum Windows Programming
    Replies: 4
    Last Post: 10-12-2001, 03:02 AM
  5. Modem programming helppp amateur!!
    By Siagal in forum C Programming
    Replies: 4
    Last Post: 10-10-2001, 05:12 AM