MFC开机自启动
看帖子,发现一个MFC开机自启动的方法,留着也许以后用的到:
[cpp]
#include <Windows.h>
#include <tchar.h>
int main(void)
{
HKEY hKey;
HKEY hNewKey;
DWORD dwDisposition=0;
__try
{
char binPath[MAX_PATH]="D:\\Program Files\\QQ\\Bin\\QQ.exe";//在这里设置你要启动的程序的路径
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS)
__leave;
if(RegSetValueEx(hKey,
_T("AutoStart"),
0,REG_SZ,(const BYTE*)binPath,
strlen(binPath)+1)!=ERROR_SUCCESS)
__leave;
}
__finally
{
RegCloseKey(hKey);
}
system("pause");
return(0);
}
摘自 开心
补充:软件开发 , Vc ,