Hi to everyone,
I have an application that needs to access a file. To know here this file was installed I place a PATH value in the Application Key at the Windows Registry.
Ussualy I use SHGetValue() and it works, however I was using it inside of a class which uses Gtkmm library. And I dont know wy but the ShlwApi.h stoped working inside this class (linking errors to the shlwapi.lib ... unresolved external...bla bla bla). So I instead of finding a solution for the lib I studied how to do without it.
I've created manually a Key at HKEY_LOCAL_MACHINE\SOFTWARE\MYAPP
and created a PATH value REG_SZ type the value at this moment has HEllo WOrld.
At this point I'm doing the following:
HKEY hkey;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,TEXT ("SOFTWARE\\MYAPP"),
0,
KEY_ALL_ACCESS,
&hkey) == ERROR_SUCCESS)
{
unsigned char rgValue [1024];
unsigned char fnlRes [1024];
DWORD size1;
DWORD type = REG_SZ;
DWORD dwRet;
size1=1023;
dwRet = RegQueryValueEx( hkey, L"PATH", NULL, &type, (unsigned char*)&rgValue, &size1);
switch (dwRet)
{
case ERROR_SUCCESS:
std::cout << "OK" << std::endl;
std::cout << rgValue << std::endl;
break;
case ERROR_MORE_DATA:
std::cout << "MORE DATA Error" << std::endl;
break;
case ERROR_FILE_NOT_FOUND:
std::cout << "File Not Found" << std::endl;
break;
default:
std::cout << "OTHER system error code" << std::endl;
break;
}
}
RegCloseKey(hkey);
-----The Output of this code is:
---- OK -> this means ERROR SUCCESS
---- H -> returns me only the first character of the string in the PATH -> should be Hello WOrld
I'm tring convertions, casts, changing type etc.. but without success.
Can you tell me what I'm doing wrong?
Thanks Apostolo