600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 设置开机时自动运行

设置开机时自动运行

时间:2020-10-25 19:43:20

相关推荐

设置开机时自动运行

void CMainFrame::EnableAutoStart()//设置程序自动开机运行

{

CString sPath;

int nPos;

HKEY RegKey;

GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);

sPath.ReleaseBuffer();

nPos=sPath.ReverseFind('\\');

sPath=sPath.Left(nPos);

CString lpszFile=sPath+"\\YbkDemo.exe";

CFileFind fFind;

BOOL bSuccess;

bSuccess=fFind.FindFile(lpszFile);

fFind.Close();

if(bSuccess)

{

CString fullName;

fullName=lpszFile;

RegKey=NULL;

RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&RegKey);

RegSetValueEx(RegKey,"彭水白云监控系统",0,REG_SZ,(const unsigned char*)(LPCTSTR)fullName,fullName.GetLength());

this->UpdateData(FALSE);

}

else

{

::AfxMessageBox("没找到执行程序,自动运行失败");

exit(0);

}

}

本文转自jazka 51CTO博客,原文链接:/jazka/188259,如需转载请自行联系原作者

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。