RegOpenKeyEx
-
Hi, i am trying to read registry key value the code is this unable to get key value whats wrong this code LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); if(ret == ERROR_SUCCESS) { RegQueryValueEx( hKey, "Version",NULL, 0, (BYTE*)value, &size); } MessageBox(value); RegCloseKey(keyHandle)
-
Hi, i am trying to read registry key value the code is this unable to get key value whats wrong this code LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); if(ret == ERROR_SUCCESS) { RegQueryValueEx( hKey, "Version",NULL, 0, (BYTE*)value, &size); } MessageBox(value); RegCloseKey(keyHandle)
What is the return value for RegQueryValueEx. You can check here[^] for the issues you can face and identify why RegQueryValueEx is failing. Below are the failure scenarios mentioned at the above location: If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a system error code. If the lpData buffer is too small to receive the data, the function returns ERROR_MORE_DATA. If the lpValueName registry value does not exist, the function returns ERROR_FILE_NOT_FOUND.
You talk about Being HUMAN. I have it in my name AnsHUMAN
-
What is the return value for RegQueryValueEx. You can check here[^] for the issues you can face and identify why RegQueryValueEx is failing. Below are the failure scenarios mentioned at the above location: If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a system error code. If the lpData buffer is too small to receive the data, the function returns ERROR_MORE_DATA. If the lpValueName registry value does not exist, the function returns ERROR_FILE_NOT_FOUND.
You talk about Being HUMAN. I have it in my name AnsHUMAN
hi, return value ERROR_FILE_NOT_FOUND. but path of key correct
-
Hi, i am trying to read registry key value the code is this unable to get key value whats wrong this code LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); if(ret == ERROR_SUCCESS) { RegQueryValueEx( hKey, "Version",NULL, 0, (BYTE*)value, &size); } MessageBox(value); RegCloseKey(keyHandle)
This does not explain why
RegQueryValueEx()
is failing, but you are displaying a value that may be invalid, and closing a key that may not have been opened. Suggest:if (ret == ERROR_SUCCESS)
{
if (RegQueryValueEx(hKey, "Version", NULL, 0, (BYTE *) value, &size) == ERROR_SUCCESS)
MessageBox(value);RegCloseKey(keyHandle)
}
Does HKLM\SOFTWARE\Apache Software Foundation\Tomcat\7.0\Tomcat7 exist? What type is
value
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
This does not explain why
RegQueryValueEx()
is failing, but you are displaying a value that may be invalid, and closing a key that may not have been opened. Suggest:if (ret == ERROR_SUCCESS)
{
if (RegQueryValueEx(hKey, "Version", NULL, 0, (BYTE *) value, &size) == ERROR_SUCCESS)
MessageBox(value);RegCloseKey(keyHandle)
}
Does HKLM\SOFTWARE\Apache Software Foundation\Tomcat\7.0\Tomcat7 exist? What type is
value
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
ret =2 that RegOpenKeyEx returns 2 LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); this not success
-
hi, return value ERROR_FILE_NOT_FOUND. but path of key correct
venkatesh52867 wrote:
but path of key correct
How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
hi, return value ERROR_FILE_NOT_FOUND. but path of key correct
Then there might be an issue in the path you create or the value type you use.
You talk about Being HUMAN. I have it in my name AnsHUMAN
-
hi, return value ERROR_FILE_NOT_FOUND. but path of key correct
Are you running a 64 bits version of Windows? For 32 bits versions running under 64 bits windows the HKEY_LOCAL_MACHINE\Software forks to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node, which could be what causes the file not found if you spelled it correctly (spaces and all).
-
ret =2 that RegOpenKeyEx returns 2 LONG ret =RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Apache Software Foundation\\Tomcat\\7.0\\Tomcat7", 0, KEY_ALL_ACCESS, &hKey); this not success