#include <windows.h>
#include <stdio.h>
int runWithWin(char *dsVal) {
long ret;
HKEY hKey;
ret = RegCreateKey (HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &hKey);
ret = RegSetValueEx (hKey, "My Application", 0, REG_SZ, dsVal, strlen(dsVal));
RegCloseKey (hKey);
return 0;
}
int main(int argn, char *argv[]) {
char mp[255];
sprintf(mp, "\"%s\"", argv[0]);
runWithWin(mp);
// do something
return 1;
}
/* Tested: Dev-C++ */
Title:
Write to registry to start with Windows
Description:
#include <windows.h> #include <stdio.h> int runWithWin(char *dsVal) { long ret; HKEY hKey; ret = RegCreateKey ...
...
Rating:
4