How to add C program in startup?

How to implement the startup in C++?
June 7th 19 at 14:55
1 answer
June 7th 19 at 14:57
Record the path to the executable of your program in the registry branch HKCU/Microsoft/Windows/Current Version/Run (instead you can use HKCU, HKLM, if you are under admin and want to set the startup for all users of the computer).
Found the solution on another Board,but there are errors. What's wrong?
HKEY hkey;
 LONG regOpenResult;
 const char PATH[] = "C:\\random folder\\random folder\\filename.exe"; // installation Path
 regOpenResult = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey);
 RegSetValueEx(hkey, "Name", REG_SZ, (BYTE*)PATH, strlen(PATH));
RegCloseKey(hkey);
 return 0;


Severity Code Description Project File Line As suppression
RegSetValueExA error C2660: function does not take 5 arguments Malware Simple c:\users\rafamont\desktop\malware simple\malware simple\source.cpp 20
Error (active) E0165 too few arguments in function call Malware Simple c:\Users\rafamont\Desktop\Malware Simple\Malware Simple\Source.cpp 20
Error (active) E0167 argument of type "size_t" is incompatible with parameter of type "const BYTE *" Malware Simple c:\Users\rafamont\Desktop\Malware Simple\Malware Simple\Source.cpp 20
Error (active) E0167 argument of type "BYTE *" is incompatible with parameter of type "DWORD" Malware Simple c:\Users\rafamont\Desktop\Malware Simple\Malware Simple\Source.cpp 20 - Nestor_Grady commented on June 7th 19 at 15:00
LONG WINAPI RegSetValueEx(
 _In_ HKEY hKey,
 _In_opt_ LPCTSTR lpValueName,
 _Reserved_ DWORD Reserved,
 _In_ DWORD dwType,
 _In_ const BYTE *lpData,
 _In_ DWORD cbData
);

you have omitted the parameter is Reserved, because of this, the settings moved out. - Tod commented on June 7th 19 at 15:03

Find more questions by tags C++