Hello guys (first post here).
I've been looking quite a while on the internet on the registry functions in Visual Studio 2010.
I've come across the functions RegOpenKeyEx and RegSetValueEx (the ones I need).
But; according to what I come across in EVERY forum; this should work:
With tbuf just holding the path name of a program.Code:HKEY hKey; RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hKey) RegSetValueEx(hKey, "TEST", 0, REG_SZ, (LPBYTE) tbuf, strlen(tbuf) + 1
Pretty normal code.
The strange part is, in the first line
The program keeps complaining that in the "SOFTWARE...etc" part, the compiler says it is not of the time LPCWSTR. Seems logical to me, but in ALL examples I found on the internet, they were NOT getting this error message.Code:RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hKey)
But even if I change the type to LPCWSTR (by just typing (LPCWSTR)"SOFTWARE... etc" I do not get an error anymore, but the program just does not work.
Can anyone explain why my compiler keeps complaining about that piece of string not being of the type LPCWSTR and ALL others don't get an error?
Thanks.




Reply With Quote