I have been in doubt about what should be a better approach:
- To cache the registry and use it later (I won't be doing it multiple times).
- To run this function when needed (if it is fast)
How can I measure the speed of this function?
int ReadUACRegistryKey(LPCWSTR key)
{
LPCWSTR pszSubKey, pszValue = key;
const std::wstring sPath = L"XXXXXXXXXXX";
pszSubKey = sSearchPattern.c_str();
DWORD dwType = 0;
DWORD dwValue = 0;
DWORD dwValueSize = sizeof(dwValue);
int retval = SHGetValue(HKEY_LOCAL_MACHINE, pszSubKey, key, &dwType, &dwValue, &dwValueSize);
if (retval != ERROR_SUCCESS)
{
Trace(TRACE_ERROR, _T("ERROR: Failed to retrieve Registry setting and check Input_Image format."));
}
return dwValue;
}```
Aucun commentaire:
Enregistrer un commentaire