- Timestamp:
- 08/24/10 15:00:17 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.
