16,473
社区成员
发帖
与我相关
我的任务
分享
BOOL SetAutoRun(CString strPath)//开机自动运行
{
CString str;
HKEY hRegKey;
BOOL bResult;
str=_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
if(RegOpenKey(HKEY_LOCAL_MACHINE, str, &hRegKey) != ERROR_SUCCESS)
bResult=FALSE;
else
{
// strPath.GetBuffer(0);
_wsplitpath(strPath.GetBuffer(0),NULL,NULL,str.GetBufferSetLength(MAX_PATH+1),NULL);
strPath.ReleaseBuffer();
str.ReleaseBuffer();
if(::RegSetValueEx( hRegKey,
str,
0,
REG_SZ,
(CONST BYTE *)strPath.GetBuffer(0),
78 ) != ERROR_SUCCESS)
bResult=FALSE;
else
bResult=TRUE;
strPath.ReleaseBuffer();
}
return bResult;
}