Witam, znalazłem i trochę zmodyfikowałem kod który dodaje wpis do rejestru żeby program uruchamiał się ze startem systemu. Niby wszystko działa, ale jak sprawdzam rejestr to nic się nie modyfikuje, możecie mnie naprowadzić co może być nie tak?
Kod:
HKEY hKey;
LPCTSTR sk = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
LONG openRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sk, 0, KEY_ALL_ACCESS , &hKey);
if (openRes==ERROR_SUCCESS) {
printf("Success opening key.");
} else {
printf("Error opening key.");
}
LPCTSTR value = TEXT("TestSoftwareKey");
LPCTSTR data = TEXT("TestData\0");
LONG setRes = RegSetValueEx (hKey, value, 0, REG_SZ, (LPBYTE)data, StringCbLength(data,100,NULL)+1);
if (setRes == ERROR_SUCCESS) {
printf("Success writing to Registry.");
} else {
printf("Error writing to Registry.");
}
LONG closeOut = RegCloseKey(hKey);
if (closeOut == ERROR_SUCCESS) {
printf("Success closing key.");
} else {
printf("Error closing key.");
}