Click to See Complete Forum and Search --> : Reading from Registry and change strings


Zoxc
May 25th, 2006, 03:38 PM
I'm trying to lauch Warcraft III World Editor by reading path from registry. The problem is that if I add something to the Path string the data from the registry disappears. The message box displays only '\worldedit.exe'. If I don't change the string the message box displays the data from registry. I'd prefer just using chars, but I got no idea of how to use those here.

PS: It's my first day of using C++ =P

if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Blizzard Entertainment\\Warcraft III", 0, KEY_READ, &TempKey) != ERROR_SUCCESS){
MessageBox(0, "Can't find Warcraft III registry information", "Error!", 0);
}

RegQueryValueEx(TempKey, "InstallPath", NULL, &DataType, NULL, &Size);
std::string Path;
RegQueryValueEx(TempKey, "InstallPath", NULL, &DataType, (LPBYTE)&Path[0], &Size);
if (Path[Size-1] != '\\') Path += "\\";
Path += "worldedit.exe";

MessageBox(0,Path.c_str(), "Error!", 0);

Brenton S.
May 25th, 2006, 08:35 PM
Hi Zoxc,

Try this:

HKEY hk;
CHAR szPath[MAX_PATH];
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Blizzard Entertainment\\Warcraft III", 0, KEY_QUERY_VALUE,
&hk);
RegQueryValueEx(hk, "InstallPath", NULL, REG_SZ, MAX_PATH);
lstrcat(szPath, "worldedit.exe");
MessageBox(NULL, szPath, NULL, MB_OK);
RegCloseKey(hk);



I hope I've been of some help.