Go to the source code of this file.
Classes | |
class | SaveRegistryEntries |
This class can be used for saving a list of items into the registry. More... | |
class | LoadRegistryEntries |
This class can be used for loading a list of items into the registry. More... | |
class | Registry |
class | RegistryEntry |
Represents an entry in the registry consisting of a key, subkeys, and some values. More... | |
class | ClassRegistryEntry |
Represents an entry in CLSID section of the registry, consisting of a key, subkeys, and some values. More... | |
class | VersionIndependentProgID |
Represents the VersionIndependentProgID key in a registry. Saves us some typing really. More... | |
class | ClassCategoryProbe |
Defines | |
#define | SAVE_PREFS_TO_REGISTRY |
Functions | |
BOOL | InitRegistry () |
In the debug version makes sure the registry contains all the items the installed normally puts in there. Also gets the handle to the key where app state information is stored. Under Win32s does nothing. | |
BOOL | DeInitRegistry () |
Shuts down the Camelot registry system, releasing any keys it holds. | |
HKEY | CreateRegKey (HKEY hKey, LPCTSTR lpcszSubKey, LPTSTR lpszClass=NULL) |
Creates a new subkey(s) under the given key. Returns NULL if something goes wrong. | |
HKEY | OpenRegKey (HKEY hKey, LPCTSTR lpcszSubKey) |
Opens a registry sub-key without creating it if it doesn't exist. | |
HKEY | OpenRegKeyReadOnly (HKEY hKey, LPCTSTR lpcszSubKey) |
Opens a registry sub-key without creating it if it doesn't exist. | |
BOOL | CloseRegKey (HKEY hKey) |
Closes a previously-opened handle to a registry key. | |
BOOL | GetRegValue (HKEY hKey, LPTSTR szValueName, LPDWORD pdwType, LPVOID pvBuf, LPDWORD pdwBufSize) |
Retrives a named value from a registry (sub)key. | |
BOOL | SetRegValue (HKEY hKey, LPCTSTR lpcszValueName, DWORD dwType, const VOID *pcData, DWORD cbData) |
Write the given value to the given key. | |
BOOL | SetRegDword (HKEY hKey, LPCTSTR lpcszValueName, DWORD Value) |
Write the given value to the given key. | |
BOOL | SetRegInt (HKEY hKey, LPCTSTR lpcszValueName, INT32 Value) |
Write the given value to the given key. | |
BOOL | SetRegBool (HKEY hKey, LPCTSTR lpcszValueName, BOOL Value) |
Write the given value to the given key. | |
BOOL | SetRegString (HKEY hKey, LPCTSTR lpcszValueName, String_256 *str) |
Write the given string to the given key. | |
BOOL | SetRegString (HKEY hKey, LPCTSTR lpcszValueName, TCHAR *str) |
Write the given string to the given key. | |
INT32 | GetRegInt (HKEY hKey, LPCTSTR szValueName) |
Retrieves an INT32 value form the registry. | |
BOOL | GetRegBool (HKEY hKey, LPCTSTR szValueName) |
Retrieves a bool value form the registry. | |
DWORD | GetRegDword (HKEY hKey, LPCTSTR szValueName) |
Retrieves a DWORD value form the registry. | |
BOOL | GetRegString (HKEY hKey, LPCTSTR szValueName, String_256 *pOut) |
Retrieves a string from the registry. If you need more control over errors you should use the general GetRegValue function. | |
BOOL | GetRegString (HKEY hKey, LPCTSTR szValueName, TCHAR *str, UINT32 str_len=256) |
Retrieves a string from the registry. If you need more control over errors you should use the general GetRegValue function. | |
BOOL | DeleteRegKey (HKEY hKey, LPCTSTR szSubKey) |
Deletes a sub-key from the registry. To be compatible with Windows NT you may only delete a sub-key that has no sub-keys itself. | |
BOOL | DeleteRegKeyAndSubKeys (HKEY hKey, LPCTSTR szSubKey) |
Deletes a sub-key and all the sub- keys of that from the registry. This is to be compatible with Windows NT as this can only delete a sub-key that has no sub-keys itself. It assumes that there are only sub-keys of the specified one i.e. it does not recursively delete the sub-keys. | |
String_256 | GetProgramNameRegistryKey () |
Returns the name that should be used as the key when accessing the registry. It should be mapped into HKEY_CURRENT_USER as the base by the OS. Used in CCamApp::InitPreferencesFilename() in the SetRegistryKey so that we load and save data out to the registry instead of to ini files. | |
BOOL | CheckForRegistryEntry (TCHAR *SubKeyName) |
BOOL | ConvertCLSIDToString (const CLSID &ID, StringBase *const pString) |
Converts a CLSID to a StringBase (39 characters if you've got it). | |
Registry * | GetLocalRegistry () |
Provides a proper interface to Registries and stuff. | |
Variables | |
TCHAR | szCamelotAppRegistryID [] |
TCHAR | szCamelotExePath [_MAX_PATH] |
HKEY | hAppStateRegKey |
const String_8 | NullString |
typedef | CATID |
Allows us to whizz through a component category picking out all the registry entries for it. At present, this class is only ever associated with the local registry. |
|
Definition at line 111 of file registry.h. |
|
Definition at line 237 of file registry.cpp. 00238 { 00239 ERROR2IF(hAppStateRegKey == NULL, FALSE, "CheckForRegistryEntry: bad main app key"); 00240 HKEY htest = OpenRegKey(hAppStateRegKey, SubKeyName); 00241 00242 // If we opened the key succesfully then it was present 00243 if (htest != 0) 00244 { 00245 CloseRegKey(htest); 00246 return TRUE; 00247 } 00248 00249 // we didn't open it successfully so it wasn't present 00250 return FALSE; 00251 }
|
|
Closes a previously-opened handle to a registry key.
Definition at line 696 of file registry.cpp.
|
|
Converts a CLSID to a StringBase (39 characters if you've got it).
Definition at line 268 of file registry.cpp. 00269 { 00270 BOOL fOk = TRUE; // return this 00271 LPOLESTR pWString = 0; 00272 fOk = (StringFromCLSID(ID, &pWString) == S_OK); 00273 00274 #ifndef _UNICODE 00275 if (fOk) 00276 { 00277 UINT32 Length = wcslen(pWString); 00278 ERROR2IF(Length != 38, FALSE, "Insufficient string size"); 00279 00280 // well it works ok for English 00281 TCHAR AString[40] = { TEXT('\0') }; 00282 for (UINT32 i = 0; i <= Length; i++) 00283 AString[i] = TCHAR(pWString[i]); 00284 00285 *pString = AString; 00286 } 00287 #else 00288 if (fOk) *pString = pWString; 00289 #endif 00290 00291 CoTaskMemFree(pWString); 00292 return fOk; 00293 }
|
|
Creates a new subkey(s) under the given key. Returns NULL if something goes wrong.
Definition at line 582 of file registry.cpp. 00583 { 00584 ERROR2IF(hKey == NULL,FALSE,"SetRegValue bad registry key!"); 00585 ERROR2IF(lpcszSubKey == NULL,FALSE,"SetRegValue bad registry key name!"); 00586 00587 // Try to create/open the given key. 00588 HKEY hkReturn; 00589 DWORD dwDisposition; 00590 00591 // Bodge fix to some bad code: We need to give an acces mask when creating the key 00592 // but the function's interface does not give us any indication of what access is needed 00593 // so just try an access mask that may well work. (Before my change we were trying to open 00594 // all regestry keys with KEY_ALL_ACCESS which appears to upset NT 4.0 quite a lot). 00595 REGSAM access = KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE | 00596 KEY_SET_VALUE | KEY_READ | KEY_WRITE; 00597 00598 INT32 nResult = ::RegCreateKeyEx(hKey, lpcszSubKey, 0, 00599 (lpszClass != NULL) ? lpszClass : TEXT(""), 00600 REG_OPTION_NON_VOLATILE, access, NULL, 00601 &hkReturn, &dwDisposition); 00602 /* 00603 #ifdef _DEBUG 00604 if (nResult != ERROR_SUCCESS) 00605 { 00606 TCHAR szBuf[256]; 00607 ::wsprintf(szBuf, TEXT("Failed - error %ld"), nResult); 00608 ::MessageBox(NULL, szBuf, TEXT("CreateRegKey"), MB_OK); 00609 } 00610 #endif 00611 */ 00612 // Did it work? 00613 return (nResult == ERROR_SUCCESS) ? hkReturn : NULL; 00614 }
|
|
Shuts down the Camelot registry system, releasing any keys it holds.
Definition at line 554 of file registry.cpp. 00555 { 00556 if (hAppStateRegKey != NULL) 00557 { 00558 BOOL closed = CloseRegKey(hAppStateRegKey); 00559 hAppStateRegKey = NULL; 00560 return closed; 00561 } 00562 00563 return TRUE; 00564 }
|
|
Deletes a sub-key from the registry. To be compatible with Windows NT you may only delete a sub-key that has no sub-keys itself.
Definition at line 880 of file registry.cpp.
|
|
Deletes a sub-key and all the sub- keys of that from the registry. This is to be compatible with Windows NT as this can only delete a sub-key that has no sub-keys itself. It assumes that there are only sub-keys of the specified one i.e. it does not recursively delete the sub-keys.
Definition at line 903 of file registry.cpp. 00904 { 00905 ERROR2IF(hKey == NULL,FALSE,"DeleteRegKeyAndSubKeys bad registry key!"); 00906 ERROR2IF(szSubKey == NULL,FALSE,"DeleteRegKeyAndSubKeys bad registry key name!"); 00907 00908 // To enumerate subkeys, an application should initially call the RegEnumKeyEx function 00909 // with the dwIndex parameter set to zero. The application should then increment the 00910 // dwIndex parameter and call RegEnumKeyEx until there are no more subkeys 00911 // (until the function returns ERROR_NO_MORE_ITEMS). 00912 // The key identified by hKey must have been opened with KEY_ENUMERATE_SUB_KEYS access 00913 // (KEY_READ includes KEY_ENUMERATE_SUB_KEYS). Use the RegCreateKeyEx or RegOpenKeyEx 00914 // function to open the key. 00915 00916 // Open up the requested sub-key 00917 HKEY hSubKey = OpenRegKey(hKey, szSubKey); 00918 if (hSubKey == NULL) 00919 return FALSE; 00920 00921 const INT32 buf_size = 256; 00922 DWORD dwIndex = 0; // index of subkey to enumerate 00923 TCHAR Name[buf_size]; // buffer for subkey name 00924 DWORD cbName = buf_size; // size of subkey buffer 00925 TCHAR Class[buf_size]; // buffer for class string 00926 DWORD cbClass = buf_size; // size of class buffer 00927 FILETIME ftLastWriteTime; // time key last written to 00928 00929 INT32 nResult = ERROR_SUCCESS; 00930 // We are going to go through evaluating all the items and add them to a list 00931 // Then we will go through the list and delete the items. 00932 // Need to do this as otherwise the enum seems to miss out half the items! 00933 // We will use LibSettingsListItem as this is just a string stored as a list item 00934 // which is all we want. 00935 List *pRegItemsList = new List; 00936 if (pRegItemsList == NULL) 00937 return FALSE; 00938 00939 String_256 KeyName; 00940 do 00941 { 00942 // reset the string sizes to their maximum for receiving data 00943 cbName = buf_size; 00944 cbClass = buf_size; 00945 // Does another sub-key exist? 00946 nResult = ::RegEnumKeyEx(hSubKey, dwIndex, Name, &cbName, NULL, Class, &cbClass, &ftLastWriteTime); 00947 if (nResult == ERROR_SUCCESS) 00948 { 00949 // we found a sub-key and so delete it 00950 KeyName = Name; 00951 LibSettingsListItem *pLibSettingsItem = new LibSettingsListItem(&KeyName); 00952 pRegItemsList->AddTail((ListItem *)pLibSettingsItem); 00953 //DeleteRegKey(hSubKey, Name); 00954 } 00955 00956 // increment our indexing item and try again 00957 dwIndex ++; 00958 00959 } while (nResult == ERROR_SUCCESS); 00960 00961 // now go through and delete the items 00962 LibSettingsListItem *pLibSettingsItem = (LibSettingsListItem *)pRegItemsList->GetHead(); 00963 while (pLibSettingsItem) 00964 { 00965 DeleteRegKey(hSubKey, *pLibSettingsItem->Line); 00966 pLibSettingsItem = (LibSettingsListItem *)pRegItemsList->GetNext(pLibSettingsItem); 00967 } 00968 00969 // delete all the list items and the list that we created 00970 pRegItemsList->DeleteAll(); 00971 delete pRegItemsList; 00972 00973 CloseRegKey(hSubKey); 00974 00975 // now delete the main sub-key 00976 DeleteRegKey(hKey, szSubKey); 00977 00978 return TRUE; 00979 }
|
|
Provides a proper interface to Registries and stuff.
Definition at line 185 of file registry.cpp. 00186 { 00187 return &g_TheLocalRegistry; 00188 }
|
|
Returns the name that should be used as the key when accessing the registry. It should be mapped into HKEY_CURRENT_USER as the base by the OS. Used in CCamApp::InitPreferencesFilename() in the SetRegistryKey so that we load and save data out to the registry instead of to ini files.
Definition at line 221 of file registry.cpp. 00222 { 00223 return TEXT( PRODUCT_MANUFACTURER "\\" PROGRAM_NAME ); 00224 }
|
|
Retrieves a bool value form the registry.
Definition at line 1057 of file registry.cpp. 01058 { 01059 ERROR2IF(hKey == NULL,FALSE,"GetRegBool bad registry key!"); 01060 ERROR2IF(szValueName == NULL,FALSE,"GetRegBool bad registry key name!"); 01061 01062 DWORD dwResult = 0; 01063 DWORD dwType = REG_DWORD; 01064 DWORD dwSize = sizeof(DWORD); 01065 if (!GetRegValue(hKey, (LPTSTR) szValueName, &dwType, &dwResult, &dwSize) || 01066 (dwType != REG_DWORD && dwType != REG_BINARY) || dwSize != sizeof(DWORD)) 01067 { 01068 // Not there or wrong type so return zero. 01069 dwResult = 0; 01070 } 01071 return (BOOL)dwResult; 01072 }
|
|
Retrieves a DWORD value form the registry.
Definition at line 997 of file registry.cpp. 00998 { 00999 ERROR2IF(hKey == NULL,FALSE,"GetRegDword bad registry key!"); 01000 ERROR2IF(szValueName == NULL,FALSE,"GetRegDword bad registry key name!"); 01001 01002 DWORD dwResult, dwType = REG_DWORD, dwSize = sizeof(DWORD); 01003 if (!GetRegValue(hKey, (LPTSTR) szValueName, &dwType, &dwResult, &dwSize) || 01004 dwType != REG_DWORD || dwSize != sizeof(DWORD)) 01005 { 01006 // Not there or wrong type so return zero. 01007 dwResult = 0; 01008 } 01009 return dwResult; 01010 }
|
|
Retrieves an INT32 value form the registry.
Definition at line 1026 of file registry.cpp. 01027 { 01028 ERROR2IF(hKey == NULL,FALSE,"GetRegInt bad registry key!"); 01029 ERROR2IF(szValueName == NULL,FALSE,"GetRegInt bad registry key name!"); 01030 01031 DWORD dwResult = 0; 01032 DWORD dwType = REG_DWORD; 01033 DWORD dwSize = sizeof(DWORD); 01034 if (!GetRegValue(hKey, (LPTSTR) szValueName, &dwType, &dwResult, &dwSize) || 01035 dwType != REG_DWORD || dwSize != sizeof(DWORD)) 01036 { 01037 // Not there or wrong type so return zero. 01038 dwResult = 0; 01039 } 01040 return (INT32)dwResult; 01041 }
|
|
Retrieves a string from the registry. If you need more control over errors you should use the general GetRegValue function.
Definition at line 1116 of file registry.cpp. 01117 { 01118 ERROR2IF(hKey == NULL,FALSE,"GetRegString bad registry key!"); 01119 ERROR2IF(szValueName == NULL,FALSE,"GetRegString bad registry key name!"); 01120 ERROR2IF(str == NULL,FALSE,"GetRegString bad return string buffer!"); 01121 01122 DWORD dwType = REG_SZ; 01123 DWORD dwSize = str_len; 01124 return GetRegValue(hKey, (LPTSTR) szValueName, &dwType, str, &dwSize) && 01125 dwType == REG_SZ && dwSize <= str_len; 01126 }
|
|
Retrieves a string from the registry. If you need more control over errors you should use the general GetRegValue function.
Definition at line 1089 of file registry.cpp. 01090 { 01091 ERROR2IF(hKey == NULL,FALSE,"GetRegString bad registry key!"); 01092 ERROR2IF(szValueName == NULL,FALSE,"GetRegString bad registry key name!"); 01093 ERROR2IF(pOut == NULL,FALSE,"GetRegString bad return string buffer!"); 01094 01095 DWORD dwType = REG_SZ, dwSize = 256; 01096 return GetRegValue(hKey, (LPTSTR) szValueName, &dwType, (LPTSTR) *pOut, &dwSize) && 01097 dwType == REG_SZ && dwSize <= 256; 01098 }
|
|
Retrives a named value from a registry (sub)key.
Definition at line 719 of file registry.cpp. 00720 { 00721 return ::RegQueryValueEx(hKey, szValueName, NULL, pdwType, (LPBYTE) pvBuf, pdwBufSize) 00722 == ERROR_SUCCESS; 00723 }
|
|
In the debug version makes sure the registry contains all the items the installed normally puts in there. Also gets the handle to the key where app state information is stored. Under Win32s does nothing.
Definition at line 359 of file registry.cpp. 00360 { 00361 #ifndef EXCLUDE_FROM_RALPH 00362 // We need to set some command lines to run the program, both here and in appstate.cpp, 00363 // so get the path to the Camelot EXE. NB. don't use that crap Marioism, the PathName 00364 // class, as it uses String_256s for full paths, but unfortunately _MAX_PATH is bigger 00365 // then that! 00366 if (::GetModuleFileName(AfxGetInstanceHandle(), szCamelotExePath, _MAX_PATH) == 0) 00367 { 00368 TRACEUSER( "JustinF", _T("GetModuleFileName failed in InitRegistry\n")); 00369 return FALSE; 00370 } 00371 00372 // Make the path into its "short form", ie. 8.3 MS-DOS compatible. This is necessary 00373 // as Windows NT doesn't like paths with spaces, even though it allows them. 00374 #ifdef _DEBUG 00375 ERROR3IF(!MakeShortPath(szCamelotExePath, _MAX_PATH), "MakeShortPath failed in InitRegistry"); 00376 #else 00377 MakeShortPath(szCamelotExePath, _MAX_PATH); 00378 #endif 00379 00380 // Under Windows 3.1 / Win32s we don't bother with anything else as there isn't a registry. 00381 if (IsWin32s() && !IsWin32c()) return TRUE; 00382 00383 // We always create the following registry entries every time the program is started. 00384 // First, set up HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER with the app's version info keys. 00385 TCHAR szProductSubkey[] = TEXT("Software\\" PRODUCT_MANUFACTURER "\\" PROGRAM_NAME); 00386 // HKEY hkProductLM = CreateRegKey(HKEY_LOCAL_MACHINE, szProductSubkey); 00387 // ERROR2IF(hkProductLM == NULL, FALSE, "Can't create LOCAL_MACHINE/Product Subkey"); 00388 00389 HKEY hkProductCU = CreateRegKey(HKEY_CURRENT_USER, szProductSubkey); 00390 ERROR2IF(hkProductCU == NULL, FALSE, "Can't create CURRENT_USER/Product Subkey"); 00391 00392 // Make some version info from the compilation definitions. 00393 TCHAR szThisVers[] = TEXT("Version " PRODUCT_VERSION_NO); 00394 DWORD dwThisBuildMajor = CAMELOT_VERSION_MAJOR, dwThisBuildMinor = CAMELOT_VERSION_MINOR; 00395 00396 // Check and if necessary update the version information in the CURRENT_USER and 00397 // LOCAL_MACHINE keys. We do this separately as the current user may not have access 00398 // to the newest version on the local machine. 00399 // BOOL fIsNewestLM = UpdateInstanceVersion(hkProductLM, 00400 // szThisVers, 00401 // dwThisBuildMajor, dwThisBuildMinor); 00402 00403 BOOL fIsNewestCU = UpdateInstanceVersion(hkProductCU, 00404 szThisVers, 00405 dwThisBuildMajor, dwThisBuildMinor); 00406 #ifdef _DEBUG 00407 if (/* fIsNewestLM || */ fIsNewestCU) 00408 TRACE( _T("Registering %s (%s)\n"), (LPCTSTR) szProductSubkey, (LPCTSTR) szThisVers); 00409 // if (fIsNewestLM) 00410 // TRACE( _T("- This is the newest version of Xara X registered on the local machine\n")); 00411 if (fIsNewestCU) 00412 TRACE( _T("- This is the newest version of Xara X registered to the current user\n")); 00413 #endif 00414 00415 // Create a version subkey under the product subkeys. We'll store the app's state under the 00416 // version key in Current Users. 00417 // ## Alex - removed "Version 3.0" from Registry!! 00418 // hAppStateRegKey = CreateRegKey(hkProductCU, szThisVers); 00419 hAppStateRegKey = CreateRegKey(HKEY_CURRENT_USER, szProductSubkey); // same as hkProductCU 00420 ERROR2IF(hAppStateRegKey == NULL, FALSE, "Can't create CURRENT_USER/AppState Subkey"); 00421 00422 00423 00424 // OK, if we aren't the newest version on the local machine we don't do anything more, as 00425 // the rest is registering shell commands etc in LOCAL_MACHINE that should always work for 00426 // the newest version globally. 00427 // if (!fIsNewestLM) 00428 // { 00429 // // We will leave the global hkAppStateRegKey open as we will close it in 00430 // // DeInitRegistry, on shutdown. 00431 // CloseRegKey(hkProductLM); 00432 // CloseRegKey(hkProductCU); 00433 // return TRUE; 00434 // } 00435 00436 // Create a version key under local machine as well. 00437 // HKEY hkVersion = CreateRegKey(hkProductLM, szThisVers); 00438 // ERROR2IF(hkVersion == NULL, FALSE, "Can't create LOCAL_MACHINE/AppState Subkey"); 00439 // CloseRegKey(hkVersion); 00440 00441 // Next, register the filename extension. 00442 // HKEY hkExtension = CreateRegKey(HKEY_CLASSES_ROOT, TEXT(PROGRAM_DOC_EXTENSION)); 00443 // ERROR2IF(hkExtension == NULL, FALSE, "Can't create " PROGRAM_DOC_EXTENSION " Subkey"); 00444 00445 00446 /* 00447 THIS IS DONE BY MFC IN CCamApp::InitInstance FOR NOW . . . 00448 00449 SetRegValue(hkExtension, NULL, REG_SZ, szCamelotAppRegistryID, sizeof(szCamelotAppRegistryID)); 00450 00451 // Next, register the application's identifier key. NB. when we get OLE working we should 00452 // also register a short name for our docs. 00453 HKEY hkAppID = CreateRegKey(HKEY_CLASSES_ROOT, szCamelotAppRegistryID); 00454 ERROR2IF(hkAppID == NULL, FALSE, "Can't create CLASSES_ROOT/AppID Subkey"); 00455 00456 // Set the ID key's sole value to the human-readable form of the document name. 00457 #ifdef _DEBUG 00458 TCHAR szAppTypeHumanName[] = TEXT(PRODUCT_PRODUCTNAME " Document (Debug)"); 00459 #else 00460 TCHAR szAppTypeHumanName[] = TEXT(PRODUCT_PRODUCTNAME " Document"); 00461 #endif 00462 SetRegValue(hkAppID, NULL, REG_SZ, szAppTypeHumanName, sizeof(szAppTypeHumanName)); 00463 00464 // Work out the command lines for opening and printing a doc. These are the app's full path 00465 // plus some parameters tagged on the end. 00466 TCHAR szOpenCmd[_MAX_PATH + 32]; 00467 ::camStrcpy(szOpenCmd, szCamelotExePath); 00468 ::camStrcat(szOpenCmd, TEXT(" %1")); 00469 00470 // Register some shell commands ... 00471 HKEY hkShellCmd = CreateRegKey(hkAppID, TEXT("shell")); 00472 ERROR2IF(hkShellCmd == NULL, FALSE, "Can't create AppID/shell Subkey"); 00473 CloseRegKey(hkAppID); 00474 00475 // ... such as the command-line used to open a doc. 00476 HKEY hkOpenVerb = CreateRegKey(hkShellCmd, TEXT("open")); 00477 ERROR2IF(hkOpenVerb == NULL, FALSE, "Can't create shell/open Subkey"); 00478 HKEY hkOpenCmd = CreateRegKey(hkOpenVerb, TEXT("command")); 00479 ERROR2IF(hkOpenCmd == NULL, FALSE, "Can't create open/command Subkey"); 00480 SetRegValue(hkOpenCmd, NULL, REG_SZ, szOpenCmd, ::camStrlen(szOpenCmd) + 1); 00481 CloseRegKey(hkOpenVerb); 00482 CloseRegKey(hkOpenCmd); 00483 */ 00484 00485 #ifndef STANDALONE 00486 /* 00487 THIS IS DONE BY MFC IN CCamApp::InitInstance FOR NOW . . . 00488 00489 // Build the command-line to print a doc (don't do print registration if this is the viewer). 00490 TCHAR szPrintCmd[_MAX_PATH + 32]; 00491 ::camStrcpy(szPrintCmd, szCamelotExePath); 00492 ::camStrcat(szPrintCmd, TEXT(" /P %1")); 00493 00494 // Register the command-line. 00495 HKEY hkPrintVerb = CreateRegKey(hkShellCmd, TEXT("print")); 00496 ERROR2IF(hkPrintVerb == NULL, FALSE, "Can't create shell/print Subkey"); 00497 HKEY hkPrintCmd = CreateRegKey(hkPrintVerb, TEXT("command")); 00498 ERROR2IF(hkPrintCmd == NULL, FALSE, "Can't create print/command Subkey"); 00499 SetRegValue(hkPrintCmd, NULL, REG_SZ, szPrintCmd, ::camStrlen(szPrintCmd) + 1); 00500 CloseRegKey(hkShellCmd); 00501 CloseRegKey(hkPrintVerb); 00502 CloseRegKey(hkPrintCmd); 00503 */ 00504 // Get the full path to the default document template. We know it should be in the same 00505 // directory as the Camelot executable, so extract the path components of the EXE path. 00506 TCHAR szDrive[_MAX_DRIVE], szDirectory[_MAX_DIR], szFileName[_MAX_FNAME], szExtn[_MAX_EXT]; 00507 SPLITPATH(szCamelotExePath, szDrive, szDirectory, szFileName, szExtn); 00508 00509 /* 00510 Doesn't look like the next 4 lines are necessary? - seeing as the code which uses 00511 szDefDocPath is already commented out. 00512 Not to mention the fact that they don't work as expected - ie _R(IDS_DEFAULTDOCNAME) 00513 resource can't be loaded from main HINSTANCE yet? Just end up with bogus string 00514 "XXXXXXX" defaulted to in SmartLoadString(UINT32 modID, UINT32 resID, LPTCHAR buf, INT32 size) 00515 after call to ::LoadString( hInst, resID, buf, size ) fails. 00516 Is _R(IDS_DEFAULTDOCNAME) in a resource DLL perhaps rather than main exe? 00517 (Ilan 23/11/99) 00518 // Now put them back together, substituting the default doc's filename. 00519 TCHAR szDefDocPath[_MAX_PATH]; 00520 String_256 strDefDocName(_R(IDS_DEFAULTDOCNAME)); 00521 MAKEPATH(szDefDocPath, szDrive, szDirectory, strDefDocName, TEXT("")); 00522 */ 00523 // TRACEUSER( "JustinF", _T("Default doc path is %s\n"), (LPCTSTR) szDefDocPath); 00524 00525 // Next, register how the shell should create a new doc for us, by copying the default 00526 // document. (The viewer has no default doc and can't create new docs). 00527 // HKEY hkShellNew = CreateRegKey(hkExtension, TEXT("ShellNew")); 00528 // ERROR2IF(hkShellNew == NULL, FALSE, "Can't create ShellNew Subkey"); 00529 // SetRegValue(hkShellNew, TEXT("FileName"), REG_SZ, szDefDocPath, ::camStrlen(szDefDocPath) + 1); 00530 // CloseRegKey(hkShellNew); 00531 #endif 00532 00533 // Success! 00534 return /* CloseRegKey(hkProductLM) && */ 00535 CloseRegKey(hkProductCU) 00536 /* && CloseRegKey(hkExtension) */ ; 00537 #else 00538 return FALSE; 00539 #endif 00540 }
|
|
Opens a registry sub-key without creating it if it doesn't exist.
Definition at line 630 of file registry.cpp. 00631 { 00632 ERROR2IF(hKey == NULL,FALSE,"OpenRegKey bad registry key!"); 00633 ERROR2IF(lpcszSubKey == NULL,FALSE,"OpenRegKey bad registry key name!"); 00634 00635 HKEY hkReturn; 00636 00637 // Bodge fix to some bad code: We need to give an acces mask when creating the key 00638 // but the function's interface does not give us any indication of what access is needed 00639 // so just try an access mask that may well work. (Before my change we were trying to open 00640 // all regestry keys with KEY_ALL_ACCESS which appears to upset NT 4.0 quite a lot). 00641 REGSAM access = KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE | 00642 KEY_SET_VALUE | KEY_READ | KEY_WRITE; 00643 00644 INT32 nResult = ::RegOpenKeyEx(hKey, lpcszSubKey, 0, access, &hkReturn); 00645 00646 if (nResult != ERROR_SUCCESS) 00647 { 00648 // Extra bodge: If the first open didn't work, try and get access with an easier going 00649 // access mask - this may make future calls on the returned HKEY fail (ie if they try to 00650 // write to it) but they were going to fail anyway. 00651 access = KEY_ENUMERATE_SUB_KEYS | KEY_EXECUTE | KEY_QUERY_VALUE | KEY_READ; 00652 00653 nResult = ::RegOpenKeyEx(hKey, lpcszSubKey, 0, access, &hkReturn); 00654 } 00655 00656 // Did it work? 00657 return (nResult == ERROR_SUCCESS) ? hkReturn : NULL; 00658 }
|
|
Opens a registry sub-key without creating it if it doesn't exist.
Definition at line 672 of file registry.cpp. 00673 { 00674 ERROR2IF(hKey == NULL,FALSE,"OpenRegKeyReadOnly bad registry key!"); 00675 ERROR2IF(lpcszSubKey == NULL,FALSE,"OpenRegKeyReadOnly bad registry key name!"); 00676 00677 HKEY hkReturn; 00678 INT32 nResult = ::RegOpenKeyEx(hKey, lpcszSubKey, 0, KEY_READ, &hkReturn); 00679 00680 // Did it work? 00681 return (nResult == ERROR_SUCCESS) ? hkReturn : NULL; 00682 }
|
|
Write the given value to the given key.
Definition at line 811 of file registry.cpp. 00812 { 00813 ERROR2IF(hKey == NULL,FALSE,"SetRegBool bad registry key!"); 00814 ERROR2IF(lpcszValueName == NULL,FALSE,"SetRegBool bad registry key name!"); 00815 00816 DWORD pcData = Value; 00817 return ::RegSetValueEx(hKey, lpcszValueName, 0, 00818 REG_BINARY, (CONST BYTE*)&pcData, sizeof(DWORD)) == ERROR_SUCCESS; 00819 }
|
|
Write the given value to the given key.
Definition at line 765 of file registry.cpp. 00766 { 00767 ERROR2IF(hKey == NULL,FALSE,"SetRegDword bad registry key!"); 00768 ERROR2IF(lpcszValueName == NULL,FALSE,"SetRegDword bad registry key name!"); 00769 00770 DWORD pcData = Value; 00771 return ::RegSetValueEx(hKey, lpcszValueName, 0, 00772 REG_DWORD, (CONST BYTE*)&pcData, sizeof(DWORD)) == ERROR_SUCCESS; 00773 }
|
|
Write the given value to the given key.
Definition at line 788 of file registry.cpp. 00789 { 00790 ERROR2IF(hKey == NULL,FALSE,"SetRegBool bad registry key!"); 00791 ERROR2IF(lpcszValueName == NULL,FALSE,"SetRegBool bad registry key name!"); 00792 00793 DWORD pcData = Value; 00794 return ::RegSetValueEx(hKey, lpcszValueName, 0, 00795 REG_DWORD, (CONST BYTE*)&pcData, sizeof(DWORD)) == ERROR_SUCCESS; 00796 }
|
|
Write the given string to the given key.
Definition at line 857 of file registry.cpp. 00858 { 00859 ERROR2IF(hKey == NULL,FALSE,"SetRegString bad registry key!"); 00860 ERROR2IF(lpcszValueName == NULL,FALSE,"SetRegString bad registry key name!"); 00861 ERROR2IF(str == NULL,FALSE,"SetRegString bad string"); 00862 00863 return SetRegValue(hKey, lpcszValueName, REG_SZ, str, ::camStrlen(str)); 00864 }
|
|
Write the given string to the given key.
Definition at line 834 of file registry.cpp. 00835 { 00836 ERROR2IF(hKey == NULL,FALSE,"SetRegString bad registry key!"); 00837 ERROR2IF(lpcszValueName == NULL,FALSE,"SetRegString bad registry key name!"); 00838 ERROR2IF(str == NULL,FALSE,"SetRegString bad string"); 00839 00840 return SetRegValue(hKey, lpcszValueName, REG_SZ, *str, str->Length()); 00841 }
|
|
Write the given value to the given key.
Definition at line 743 of file registry.cpp. 00744 { 00745 ERROR2IF(hKey == NULL,FALSE,"SetRegValue bad registry key!"); 00746 ERROR2IF(pcData == NULL,FALSE,"SetRegValue bad registry key name!"); 00747 00748 return ::RegSetValueEx(hKey, lpcszValueName, 0, 00749 dwType, (CONST BYTE*) pcData, cbData) == ERROR_SUCCESS; 00750 }
|
|
Allows us to whizz through a component category picking out all the registry entries for it. At present, this class is only ever associated with the local registry.
Definition at line 352 of file registry.h. |
|
Definition at line 205 of file registry.cpp. |
|
Definition at line 151 of file tmpltatr.cpp. |
|
Definition at line 199 of file registry.cpp. |
|
Definition at line 202 of file registry.cpp. |