您的位置:首页 > 其它

开机自动运行

2007-06-07 16:48 288 查看
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
{
_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),
strPath.GetLength() ) != ERROR_SUCCESS)
bResult=FALSE;
else
bResult=TRUE;
strPath.ReleaseBuffer();
}
return bResult;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: