#include <stdio.h>
#include <windows.h>
int main(int argc, char* argv[])
{
HKEY RegOpenHandle;
if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", NULL,
KEY_ALL_ACCESS, &RegOpenHandle) == ERROR_SUCCESS )
{
char MHValue[MAX_PATH];
strcpy(MHValue, "c:\\windows\\system32\\notepad.exe");
if( RegSetValueEx(RegOpenHandle, "notepad", NULL, REG_SZ, (const unsigned char *)&MHValue, lstrlen(MHValue))
== ERROR_SUCCESS)
{
printf("修改启动项成功\n");
RegCloseKey( RegOpenHandle );
}
else
{
printf("修改启动项失败\n");
}
}
else
{
printf("打开指定键值失败!\n");
}
system("pause");
return 0;
}
开机启动项其它路径:
HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\RunHKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\ Current Version\\Windows\\load