// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved. /* * profile.cpp * * win32/win16 utility functions to read and write profile items * for VFW * * When a profile call * is made the code looks for an atom to correspond to the appname supplied. * If an atom is found, then the table of cached registry keys is searched * for the matching registry handle. If the handle exists, it is used. * No handle would mean that someone else registered an atom using this * name, so we proceed to the next step. * * No atom found, or no matching registry handle, means that we have to * open a registry key. If successful, and there is space in the cache, * we AddAtom the appname, and cache the registry key before returning to * the caller. */ #include "precomp.h" #ifdef _WIN32 #include "profile.key" #include "mmsystem.h" #include "profile.h" #ifdef USESTRINGSALSO #include /* for atoi */ #endif #if MMPROFILECACHE #ifdef DEBUG #define KEYSCACHED 3 #else #define KEYSCACHED 2 #endif HKEY ahkey[KEYSCACHED]; ATOM akeyatoms[KEYSCACHED]; UINT keyscached = 0; #else #define KEYSCACHED 0 #endif 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