RegOpenKeyEx returning strange error
-
I have been trying to open particular registry key to know the version of Outlook currently installed on the PC. Here is the piece of code HKEY hKey; CString strKey = _T("Outlook.Application\\CurVer"); if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // do something } else { DWORD dwError = GetLastError(); } The above piece of code fails to open the registry key and the GetLastError() returns error no. 122 which says "The data area passed to the system call is too small" I have administrative privilege on the PC, but this piece of code fails to open the key, what could be the reason, and how do I interpret the error returned? Thanx.
-
I have been trying to open particular registry key to know the version of Outlook currently installed on the PC. Here is the piece of code HKEY hKey; CString strKey = _T("Outlook.Application\\CurVer"); if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // do something } else { DWORD dwError = GetLastError(); } The above piece of code fails to open the registry key and the GetLastError() returns error no. 122 which says "The data area passed to the system call is too small" I have administrative privilege on the PC, but this piece of code fails to open the key, what could be the reason, and how do I interpret the error returned? Thanx.
vipin_nvk wrote:
if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"... I'm not sure,whther this will work ..but try...
Born to win...!
-
vipin_nvk wrote:
if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"... I'm not sure,whther this will work ..but try...
Born to win...!
This piece of code works fine at my place but fails with the above mentioned error at the client's place, so I wanted to know as to what could lead to the ERROR_INSUFFICIENT_BUFFER error so that it can be fixed and then sent across to the client. Do you think changing access to KEY_ALL_ACCESS will really work?
-
This piece of code works fine at my place but fails with the above mentioned error at the client's place, so I wanted to know as to what could lead to the ERROR_INSUFFICIENT_BUFFER error so that it can be fixed and then sent across to the client. Do you think changing access to KEY_ALL_ACCESS will really work?
vipin_nvk wrote:
Do you think changing access to KEY_ALL_ACCESS will really work?
No, the changing key access ...it wont solve ur problem.. It's something related to other problem... :(
Born to win...!
-
vipin_nvk wrote:
if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"... I'm not sure,whther this will work ..but try...
Born to win...!
Manivannan@congruent wrote:
Change the parameter value instead of "KEY_READ" give "KEY_ALL_ACCESS"...
As a matter of fact, that is a very bad suggestion. You should open a registry key only with the privileges that you may actually need.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
I have been trying to open particular registry key to know the version of Outlook currently installed on the PC. Here is the piece of code HKEY hKey; CString strKey = _T("Outlook.Application\\CurVer"); if (::RegOpenKeyEx(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // do something } else { DWORD dwError = GetLastError(); } The above piece of code fails to open the registry key and the GetLastError() returns error no. 122 which says "The data area passed to the system call is too small" I have administrative privilege on the PC, but this piece of code fails to open the key, what could be the reason, and how do I interpret the error returned? Thanx.
Have you tried:
HKEY hKey;
LONG lResult = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("Outlook.Application\\CurVer"), 0, KEY_READ, &hKey);
if (lResult == ERROR_SUCCESS)
{
// do something
}
else
{
LPVOID lpMsgBuf;FormatMessage(FORMAT\_MESSAGE\_ALLOCATE\_BUFFER | FORMAT\_MESSAGE\_FROM\_SYSTEM, NULL, lResult, MAKELANGID(LANG\_NEUTRAL, SUBLANG\_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL); ... LocalFree(lpMsgBuf);
}
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne