GetModuleFileName, f.ex:
#include <windows.h>
#include <iostream>
int main()
{
char Name[1024];
GetModuleFileName(0, Name, sizeof(Name));
std::cout << "MyName is: " << Name << std::endl;
return 0;
}
Ved godt jeg er lidt krævende, men kan få dig til at sætte det ind i denne kode:
char Name[1024] = GetModuleFileName(0, Name, sizeof(Name));
HKEY hKey;
char ProgramName[] = "D:\\\\NetS.exe";
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0) == ERROR_SUCCESS)
{
RegSetValueEx(hKey, "NetS", 0, REG_SZ, (BYTE *)Name, strlen(ProgramName) + 1);
std::cout << "Did write value" << std::endl;
}
else
std::cout << "Failed to write value" << std::endl;
RegCloseKey(hKey);
Synes ikke lige jeg kan få den til at virke.
//Nick