static HKEY GetKeyA(LPCSTR appname, BOOL * closekey, BOOL fCreate) { HKEY key = 0; char achName[MAX_PATH]; HRESULT hr; #if !MMPROFILECACHE *closekey = TRUE; #else UINT n; ATOM atm; *closekey = FALSE; // // See if we have already used this key // atm = FindAtomA(appname); if (atm != 0) { // Atom exists... search the table for it. for (n=0; n<keyscached; ++n) { if (akeyatoms[n] == atm) { DPF2(("Found existing key for %s\n", appname)); return ahkey[n]; } } } DPF2(("No key found for %s", appname)); #endif hr = StringCchCopyA(achName, MAX_PATH, KEYNAMEA); if (FAILED(hr)) OutputError(hr, IDS_SAFE_COPY); if ((!fCreate && RegOpenKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS) || (fCreate && RegCreateKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)) { #if MMPROFILECACHE if ((keyscached < KEYSCACHED) && (atm = AddAtomA(appname))) { // Add this key to the cache array akeyatoms[keyscached] = atm; ahkey[keyscached] = key; DPF1(("Adding key %s to cache array in position %d\n", appname, keyscached)); ++keyscached; } else { DPF2(("Not adding key %s to cache array\n", appname)); *closekey = TRUE; } #endif } return(key); }
static HKEY GetKeyA(LPCSTR appname, BOOL * closekey, BOOL fCreate) { HKEY key = 0; char achName[MAX_PATH]; #if !MMPROFILECACHE *closekey = TRUE; #else UINT n; ATOM atm; *closekey = FALSE; // // See if we have already used this key // atm = FindAtomA(appname); if (atm != 0) { // Atom exists... search the table for it. for (n=0; n<keyscached; ++n) { if (akeyatoms[n] == atm) { DPF2(("Found existing key for %s\n", appname)); return ahkey[n]; } } } DPF2(("No key found for %s", appname)); #endif lstrcpyA(achName, KEYNAMEA); // Use registry under "CURRENT_USER\Software\Microsoft\Windiff\" //lstrcatA(achName, appname); if ((!fCreate && RegOpenKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS) || (fCreate && RegCreateKeyA(ROOTKEY, achName, &key) == ERROR_SUCCESS)) { #if MMPROFILECACHE if ((keyscached < KEYSCACHED) && (atm = AddAtomA(appname))) { // Add this key to the cache array akeyatoms[keyscached] = atm; ahkey[keyscached] = key; DPF1(("Adding key %s to cache array in position %d\n", appname, keyscached)); ++keyscached; } else { DPF2(("Not adding key %s to cache array\n", appname)); *closekey = TRUE; } #endif } return(key); }
static HKEY GetKeyW(LPCWSTR appname, BOOL * closekey, BOOL fCreate) { HKEY key = 0; WCHAR achName[MAX_PATH]; #if !MMPROFILECACHE *closekey = TRUE; #else UINT n; ATOM atm; *closekey = FALSE; // // See if we have already used this key // atm = FindAtomW(appname); if (atm != 0) { // Atom exists... search the table for it. for (n=0; n<keyscached; ++n) { if (akeyatoms[n] == atm) { DPF2(("(W)Found existing key for %ls\n", appname)); return ahkey[n]; } } } DPF2(("(W)No key found for %ls\n", appname)); #endif StringCchCopyW(achName, MAX_PATH, KEYNAME ); StrCchCatW(achName, MAX_PATH, appname); if ((!fCreate && RegOpenKeyW(ROOTKEY, achName, &key) == ERROR_SUCCESS) || (fCreate && RegCreateKeyW(ROOTKEY, achName, &key) == ERROR_SUCCESS)) { #if MMPROFILECACHE if (keyscached < KEYSCACHED && (atm = AddAtomW(appname))) { // Add this key to the cache array akeyatoms[keyscached] = atm; ahkey[keyscached] = key; DPF1(("Adding key %ls to cache array in position %d\n", appname, keyscached)); ++keyscached; } else { DPF2(("Not adding key to cache array\n")); *closekey = TRUE; } #endif } return(key); }