Answer the question
In order to leave comments, you need to log in
Does not write to the c++ registry. What to do?
Hello friends, I haven’t been sleeping for 2 days trying to implement a c ++ registry entry for auto start, below I will present the code to you, the problem is that it does not write to the registry.
BOOL AutoRunViaRegedit(wchar_t* path) {
HKEY hKey;
if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueEx(hKey, L"Test", 0, REG_SZ, (LPBYTE)path, sizeof(path));
RegCloseKey(hKey);
}
return true;
}
Answer the question
In order to leave comments, you need to log in
I found a problem in 19 studios, over choosing all platforms, and not 32 bit when building, then everything works.
wchar_t* path
pointer?
sizeof(path)
pointer size?
Does the program compile as x86? If yes, and windows x64, then you need to specify which registry branch to write to. This is done through the KEY_WOW64_64KEY flag.
Read more here: https://docs.microsoft.com/en-us/windows/win32/sys...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question