1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <Windows.h>
void addToStartup(const char *path, const char *name, int state);
int main(int argc, char *argv[]) {
FreeConsole();
MessageBox(NULL, TEXT("test"), TEXT("titre"), MB_OK);
addToStartup("C:\\Documents and Settings\\vador\\Bureau", "test.exe", 1);
return 0;
}
void addToStartup(const char *path, const char *name, int state) {
HKEY key;
RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &key);
if(state) {
RegSetValueEx(key, name, 0, REG_SZ, (BYTE*)path, strlen(path)+1);
} else {
RegDeleteValue(key, name);
}
RegCloseKey(key);
return;
} |
Partager