SC_HANDLE Helppp!

This is a discussion on SC_HANDLE Helppp! within the C++ Programming forums, part of the General Programming Boards category; Can anyone tell me why the following piece of code gives an error of undeclared identifier for the SC_HANDLE declarations? ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    12

    SC_HANDLE Helppp!

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


    Code:
    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");
             return(0);
             }
    
        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");
                            return(0);
                    case ERROR_INVALID_NAME:
                            printf("PortTalk: The specified service name is invalid.\n");
                            return(0);
                    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");
                            InstallPortTalkDriver();
                            break;
                }
             } 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");
              return(0);
            }
        }
    
        /* Close handle to Service Control Manager */
        CloseServiceHandle (schService);
        return(TRUE);
    }
    many thanks
    Bazzz


    Code tags added by Kermi3

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

    Information on code tags may be found at:

    http://www.cprogramming.com/cboard/s...threadid=13473
    Kermi3

    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
    Posts
    6,231
    >>SC_HANDLE
    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, 12:57 PM
  2. helppp in bank databse
    By neha007 in forum C++ Programming
    Replies: 1
    Last Post: 06-02-2007, 10: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, 04:02 AM
  5. Modem programming helppp amateur!!
    By Siagal in forum C Programming
    Replies: 4
    Last Post: 10-10-2001, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21