//开机启动 int CMainWnd::CreateRun() { //添加以下代码 HKEY hKey; char pFileName[MAX_PATH] = {0}; //得到程序自身的全路径 DWORD dwRet = GetModuleFileNameW(NULL, (LPWCH)pFileName, MAX_PATH); //找到系统的启动项 LPCTSTR lpRun = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); //打开启动项Key long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey); if(lRet== ERROR_SUCCESS) { //添加注册 RegSetValueEx(hKey, _T("UilibDemo"), 0,REG_SZ,(const BYTE*)(LPCSTR)pFileName, MAX_PATH); RegCloseKey(hKey); } return 0; } //取消开机启动 int CMainWnd::DeleteRun() { //添加以下代码 HKEY hKey; char pFileName[MAX_PATH] = {0}; //得到程序自身的全路径 DWORD dwRet = GetModuleFileNameW(NULL, (LPWCH)pFileName, MAX_PATH); //找到系统的启动项 LPCTSTR lpRun = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); //打开启动项Key long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey); if(lRet== ERROR_SUCCESS) { //删除注册 RegDeleteValue(hKey,_T("UilibDemo")); RegCloseKey(hKey); } return 0; }
vc++ 程序开机自启动和取消启动
转载上一篇:VC++ 关闭防火墙,写入注册表
下一篇:DirectUI
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
winform程序 开机自启动
参考资料:https://www.jb51.net/article/149734.htm 橘子Jane
javascript 参考资料 .net -
mysql yum 卸载取消开机自启动
查询安装的yum源rpm -qa | gre
mysql yum源 开机自启