|
-
February 6th, 2004, 06:31 PM
#1
Help with registry key value.
How to determine using WINAPI registry means whether the registry key exists???
-
February 6th, 2004, 06:41 PM
#2
Do you want to create the key if it does not exist?
If so, then you could use RegCreateKeyEx. It will create the key if it does not exist, and it will open the key if it does exist. Then you could check the value of lpdwDisposition to see whether it created the key or opened it.
-
February 6th, 2004, 06:48 PM
#3
Here is an example of doing it using RegCreateKeyEx.
Code:
HKEY phkResult;
DWORD lpdwDisposition;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\My Programs\\My Program"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &phkResult, &lpdwDisposition);
if (lpdwDisposition == REG_CREATED_NEW_KEY) // key did not exist
{
// set default registry values for your program
}
// Read in your values
One way of doing it...
-
February 6th, 2004, 06:52 PM
#4
No, I want to query it's value, but the returned result is ERROR_FILE_NOT_FOUND.
Does this returned result mean that the key doesn't exist in this context???
-
February 6th, 2004, 07:05 PM
#5
Yes, you would receive that error as returned by RegOpenKeyEx if the key did not exist.
-
February 6th, 2004, 07:17 PM
#6
Is that what you were looking for, or are you having problems opening a key that you know exits (if so, posting the related code would help)?
-
February 6th, 2004, 07:46 PM
#7
Yes, thanx. I just wanted to be sure in the meaning of the return code.
But the function that I am using is RegQueryValueEx, but I think it doesn't matter in this case.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|