I have a setup program for an application which now stores the path name for my application in the registry. It is found under the following key:
When running my application needs to access two other executable files and also two text files which are either stored in the same location as the main application or in subfolders. I now know that to retrieve the path information I need to use the RegOpenKeyEx and RegqueryValueEx functions.
Am I right in saying that the RegOpenKeyEx function simply opens the key underwhich my path information is stored? And then the RegqueryValueEx function is used to retrieve the information?
My problem is with the RegqueryValueEx function, I'm not sure of what the parameters are, how the value is returned and then how to use it. This is probably best illustrated with an example.
//Now opened the key with MyHKEY_Software containing address of handle to open key
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Litriu.exe",0,KEY_ALL_ACCESS, &MyHKEY_Software);
\\Now need to retrieve the data for the 'path'
unsigned long SizeOfBuf = sizeof(MyProgramPath);
unsigned long MyREG_Size;
RegQueryValueEx(MyHKEY_Software,"Path", 0, &MyREG_Size, (unsigned char *)MyProgramPath,
\\Does this mean that the path name is now stored in MyProgramPath?
How do I open a text file stored at that location?
I tried stuff like this but it wouldn't work:
ifstream InDictFile(MyProgramPath + "list.txt", ios::in);
I know this probably seems simple to most people but i need someone to explain exactly how the last three parameters work in the RegqueryValueEx function.