Changeset 101
- Timestamp:
- 08/24/10 14:00:17 (18 months ago)
- Location:
- trunk/sources/win32service
- Files:
-
- 4 edited
-
svcconfig/src/svcconfig.cpp (modified) (5 diffs)
-
win32service/include/svc/serviceregistry.h (modified) (1 diff)
-
win32service/src/svc/serviceregistry.cpp (modified) (5 diffs)
-
win32service/src/svc/svc.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/win32service/svcconfig/src/svcconfig.cpp
r86 r101 132 132 { 133 133 printf("QueryServiceConfig failed (%d)", dwError); 134 goto cleanup; 134 135 return false; 135 goto cleanup;136 136 } 137 137 } … … 144 144 { 145 145 printf("QueryServiceConfig failed (%d)", GetLastError()); 146 goto cleanup; 146 147 return false; 147 goto cleanup;148 148 } 149 149 … … 164 164 { 165 165 printf("QueryServiceConfig2 failed (%d)", dwError); 166 goto cleanup; 166 167 return false; 167 goto cleanup;168 168 } 169 169 } … … 177 177 { 178 178 printf("QueryServiceConfig2 failed (%d)", GetLastError()); 179 goto cleanup; 179 180 return false; 180 goto cleanup;181 181 } 182 182 … … 201 201 LocalFree(lpsc); 202 202 LocalFree(lpsd); 203 return true; 203 goto success; 204 204 205 cleanup: 205 206 CloseServiceHandle(schService); 206 207 CloseServiceHandle(schSCManager); 208 209 success: 210 return true; 207 211 } 208 212 -
trunk/sources/win32service/win32service/include/svc/serviceregistry.h
r97 r101 5 5 char * QueryKey(HKEY hKey); 6 6 HKEY AddKey(); 7 voidSetKeyValue(HKEY hKey);7 DWORD SetKeyValue(HKEY hKey); 8 8 9 char * GetSvcRegistry();9 char * SvcRegistry(int action); 10 10 char * FormatWindowsError(int nError); -
trunk/sources/win32service/win32service/src/svc/serviceregistry.cpp
r97 r101 8 8 #define MAX_VALUE_NAME 16383 9 9 10 char * GetSvcRegistry()10 char * SvcRegistry(int action) 11 11 { 12 12 HKEY hTestKey; 13 13 HKEY hSvcKey; 14 14 DWORD retCode; 15 char * config_path = " path";15 char * config_path = ""; 16 16 17 17 retCode = RegOpenKeyEx( HKEY_LOCAL_MACHINE, … … 23 23 if( retCode == ERROR_SUCCESS) 24 24 { 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 27 46 { 28 SetKeyValue(hSvcKey); 29 config_path = QueryKey(AddKey()); 30 printf("\n configuration path: %s\n", config_path); 47 return REGIST_ERROR; 31 48 } 49 32 50 } else 33 51 { … … 35 53 return REGIST_ERROR; 36 54 } 37 38 RegCloseKey(hTestKey);39 40 return config_path;41 42 55 } 43 56 … … 67 80 } 68 81 69 voidSetKeyValue(HKEY hKey)82 DWORD SetKeyValue(HKEY hKey) 70 83 { 71 84 DWORD retCode; … … 77 90 else 78 91 printf("\n ERROR setting path as key value (%d): %s\n", retCode, FormatWindowsError(retCode)); 92 93 return retCode; 79 94 } 80 95 -
trunk/sources/win32service/win32service/src/svc/svc.cpp
r97 r101 28 28 if( lstrcmpi( argv[1], TEXT("installService")) == 0 ) 29 29 { 30 if( GetSvcRegistry() != REGIST_ERROR)30 if(SvcRegistry(ADD_KEY) != REGIST_ERROR) 31 31 SvcInstall(); 32 32 else … … 65 65 if ( argc == 1 ) //if no argument, assume that rtmpserver is started normally 66 66 { 67 if (!DoQuerySvc ){67 if (!DoQuerySvc()){ 68 68 printf("Server will start normally.\n\n"); 69 rtmpserver( GetSvcRegistry());69 rtmpserver(SvcRegistry(GET_KEY_VALUE)); 70 70 return; 71 71 }else{ 72 72 printf("\nERROR: Server cannot be started normally because the service described above is already installed. .\n\n"); 73 73 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");75 74 return; 76 75 } … … 96 95 printf("\t stopService\n"); 97 96 printf("Run as stand-alone:\n"); 98 printf("\twin32service <configfile path>\n"); 99 printf("\twin32service --use-implicit-console-appender\n"); 97 printf("\twin32service\n"); 100 98 } 101 99 //
Note: See TracChangeset
for help on using the changeset viewer.
