开机自动运行
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;
}
{
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;
}
相关文章推荐
- WinCE 应用程序开机自动运行的又一种方法
- fedora16中利用rc.local实现开机自动运行mentohust
- windows开机自动运行注册表项
- Linux--设置开机自动运行程序
- C# winform利用注册表信息实现开机自动运行软件
- 开机自动运行的几个途径
- Linux、UNIX设置开机自动运行命令、脚本配置
- redmine 开机自动运行
- linux 开机自动运行
- ubuntu14.04 开机自动运行应用程序
- openSUSE下开机自动运行脚本命令的方法
- linux下怎么使SSH服务开机自动运行?
- Android实现开机自动运行程序
- 开机自动运行---/etc/init.d/rcS 分析【转】
- 在Linux中开机自动运行普通用户脚本程序
- 在Linux中,开机自动运行普通用户的脚本程序
- Wince系统开机自动运行指定应用程序
- linux 开机自动运行sh脚本
- linux 如何开机自动运行sh脚本
- WinCE 应用程序开机自动运行的又一种方法