1、注册表修改
<略>
2、修改[win.ini]文件
CString strFileName = "D://autostart//Debug//autostart.exe";
LPCTSTR filename = strFileName;
int ires = 0;
ires = WritePrivateProfileString(_T("windows"),_T("load"),filename,_T("c://windows//win.ini"));
if(ires == 0)
{
MessageBox("fail");
}
ires = WritePrivateProfileString(_T("windows"),_T("run"),filename,_T("c://windows//win.ini"));
if(ires == 0)
{
MessageBox("fail");
}
MessageBox("OK");
3、添加到【开始】【程序】【启动】
char Benshen[MAX_PATH];
char System[MAX_PATH];
int ret;
GetModuleFileName(NULL,Benshen,MAX_PATH);//这个就是GetModuleFileName函数
GetSystemDirectory(System ,MAX_PATH+1);//GetSystemDirectory函数
System[2] = '/0';
strcat(System,"//Documents and Settings//Administrator//「开始」菜单//程序//启动//程序.exe");
ret = CopyFile(Benshen, System, FALSE);
if(ret == 0)
{
MessageBox("fail");
}