TCHAR *EventName = NULL;
DWORD Result;
HKEY hKey;
DWORD NumBytes = 0;
DWORD Type;
HANDLE UserEvent = INVALID_HANDLE_VALUE;
// Open the Registry Key
Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCWSTR)GWE_REG_PATH, 0, 0, &hKey);
if( ERROR_SUCCESS == Result )
{
// This is a fake read, all it does is fill in NumBytes with the number of
// bytes in the string value plus the null character.
Result = RegQueryValueEx( hKey, ACTIVITY_VALUE, NULL, &Type, NULL, &NumBytes );
if( NumBytes > 0 )
{
// Now we know how big the string is allocate and read it
EventName = (TCHAR *)malloc( NumBytes );
if( EventName != NULL )
Result = RegQueryValueEx( hKey, ACTIVITY_VALUE, NULL, &Type,
(LPBYTE)EventName, &NumBytes );
}
RegCloseKey( hKey );
UserEvent = CreateEvent( NULL, FALSE, FALSE, EventName );
free( EventName );
}
// Do something with UserEvent