Answer the question
In order to leave comments, you need to log in
Why not autoload code via C++ registry?
void AutoRun()
{
char arr[MAX_PATH] = { };
GetModuleFileName(NULL, (LPWSTR)arr, MAX_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)
{
if (RegSetValueEx(hKey, L"svchost", NULL, REG_SZ, (LPBYTE)arr, (sizeof(arr) + 1)) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
}
return;
}
}
Answer the question
In order to leave comments, you need to log in
Your code does not match the screenshot (the name is different).
Look through regedit to see what is being written to the registry.
You don't see any error handling. Do both functions return ERROR_SUCCESS?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question