hi All,
I have a function that reads string values from the registry:
Code:
char *readregistry(char keyname[50], char keyvalue[20])
{
BOOL ret, success;
HKEY keyhandle;
DWORD dwBufLen = 32;
char myregval[100];
char *str= (char *)malloc(100);
if (str == NULL)
{ cout << "Error allocating memory";
exit(1);
}
ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,keyname,0,KEY_READ,&keyhandle);
if (ret != ERROR_SUCCESS)
{
strcpy(str, "NONE");
return str;
}
else
{
success= RegQueryValueEx(keyhandle, keyvalue, NULL, NULL, (LPBYTE)myregval, &dwBufLen);
if (success != ERROR_SUCCESS) {
strcpy(str, "NONE");
return str;
}
else
{ strcpy(str, myregval);
return str;
}
}
}
This normally works fine however if I am trying to read a unc network path from the registry some times it fails and returns 'NONE'.
For instance it cannot read this value:
\\computername\share\directory\subdirectory\
But it can read this:
\\computername\share\directory\
Any thoughts as to how to get around this problem?
Thanks in advance..
Aaron