Changeset 101


Ignore:
Timestamp:
08/24/10 14:00:17 (18 months ago)
Author:
jay
Message:

-- fixed bug in starting server normally.

Location:
trunk/sources/win32service
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/win32service/svcconfig/src/svcconfig.cpp

    r86 r101  
    132132        { 
    133133            printf("QueryServiceConfig failed (%d)", dwError); 
     134            goto cleanup;  
    134135                        return false; 
    135             goto cleanup;  
    136136        } 
    137137    } 
     
    144144    { 
    145145        printf("QueryServiceConfig failed (%d)", GetLastError()); 
     146        goto cleanup; 
    146147                return false; 
    147         goto cleanup; 
    148148    } 
    149149 
     
    164164        { 
    165165            printf("QueryServiceConfig2 failed (%d)", dwError); 
     166            goto cleanup;  
    166167                        return false; 
    167             goto cleanup;  
    168168        } 
    169169    } 
     
    177177    { 
    178178        printf("QueryServiceConfig2 failed (%d)", GetLastError()); 
     179        goto cleanup; 
    179180                return false; 
    180         goto cleanup; 
    181181    } 
    182182  
     
    201201    LocalFree(lpsc);  
    202202    LocalFree(lpsd); 
    203         return true; 
     203        goto success; 
     204 
    204205cleanup: 
    205206    CloseServiceHandle(schService);  
    206207    CloseServiceHandle(schSCManager); 
     208 
     209success: 
     210        return true; 
    207211} 
    208212 
  • trunk/sources/win32service/win32service/include/svc/serviceregistry.h

    r97 r101  
    55char * QueryKey(HKEY hKey); 
    66HKEY AddKey(); 
    7 void SetKeyValue(HKEY hKey); 
     7DWORD SetKeyValue(HKEY hKey); 
    88 
    9 char * GetSvcRegistry(); 
     9char * SvcRegistry(int action); 
    1010char * FormatWindowsError(int nError); 
  • trunk/sources/win32service/win32service/src/svc/serviceregistry.cpp

    r97 r101  
    88#define MAX_VALUE_NAME 16383 
    99 
    10 char * GetSvcRegistry() 
     10char * SvcRegistry(int action) 
    1111{ 
    1212        HKEY hTestKey; 
    1313        HKEY hSvcKey; 
    1414        DWORD retCode; 
    15         char * config_path = "path"; 
     15        char * config_path = ""; 
    1616 
    1717        retCode = RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
     
    2323   if( retCode == ERROR_SUCCESS) 
    2424   { 
    25            hSvcKey = AddKey(); 
    26            if(hSvcKey != NULL) 
     25           hSvcKey = AddKey();//Creates the key if the key does not exist. If it does, it reads the key value. 
     26           if(hSvcKey != NULL){ 
     27                   switch (action) 
     28                   { 
     29                   case ADD_KEY: 
     30                           if(SetKeyValue(hSvcKey) != ERROR_SUCCESS) 
     31                                   return REGIST_ERROR; 
     32                           else { 
     33                                   RegCloseKey(hTestKey); 
     34                                   return REGIST_SUCCESS; 
     35                           } 
     36                           break; 
     37 
     38                   case GET_KEY_VALUE: 
     39                           config_path = QueryKey(hSvcKey); 
     40                           printf("\n configuration path: %s\n", config_path); 
     41                           RegCloseKey(hTestKey); 
     42                           return config_path; //Return the config file path 
     43                           break; 
     44                   } 
     45           }else 
    2746           { 
    28                    SetKeyValue(hSvcKey); 
    29                    config_path = QueryKey(AddKey()); 
    30                    printf("\n configuration path: %s\n", config_path); 
     47                   return REGIST_ERROR; 
    3148           } 
     49 
    3250   } else 
    3351   { 
     
    3553           return REGIST_ERROR; 
    3654   } 
    37     
    38    RegCloseKey(hTestKey); 
    39     
    40    return config_path; 
    41  
    4255} 
    4356 
     
    6780} 
    6881 
    69 void SetKeyValue(HKEY hKey) 
     82DWORD SetKeyValue(HKEY hKey) 
    7083{ 
    7184        DWORD retCode; 
     
    7790        else 
    7891           printf("\n ERROR setting path as key value (%d): %s\n", retCode, FormatWindowsError(retCode)); 
     92 
     93        return retCode; 
    7994} 
    8095 
  • trunk/sources/win32service/win32service/src/svc/svc.cpp

    r97 r101  
    2828    if( lstrcmpi( argv[1], TEXT("installService")) == 0 ) 
    2929    { 
    30                 if(GetSvcRegistry() != REGIST_ERROR) 
     30                if(SvcRegistry(ADD_KEY) != REGIST_ERROR) 
    3131                        SvcInstall(); 
    3232                else 
     
    6565                if ( argc == 1 ) //if no argument, assume that rtmpserver is started normally 
    6666                { 
    67                         if (!DoQuerySvc){ 
     67                        if (!DoQuerySvc()){ 
    6868                                printf("Server will start normally.\n\n"); 
    69                                 rtmpserver(GetSvcRegistry()); 
     69                                rtmpserver(SvcRegistry(GET_KEY_VALUE)); 
    7070                                return; 
    7171                        }else{ 
    7272                                printf("\nERROR: Server cannot be started normally because the service described above is already installed. .\n\n"); 
    7373                                printf("Start/Stop the server by starting/stopping the service.\n\n"); 
    74                                 printf("To start server normally, enter 'uninstallService' command to delete the service.\n\n"); 
    7574                                return; 
    7675                        } 
     
    9695    printf("\t  stopService\n"); 
    9796        printf("Run as stand-alone:\n"); 
    98         printf("\twin32service <configfile path>\n"); 
    99         printf("\twin32service --use-implicit-console-appender\n"); 
     97        printf("\twin32service\n"); 
    10098} 
    10199// 
Note: See TracChangeset for help on using the changeset viewer.