Hi Andy,
Sorry, I don't understand what I have done wrong. RegCloseKey() will return ERROR_INVALID_HANDLE if called with hkey==NULL.
To expand on James's brief response,
- HKEY userdata;
- HKEY userdata = NULL;
This change looks correct, but the other isn't necessary. --Juan