📄 autorun.cpp
字号:
// AutoRun.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "AutoRun.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
HKEY hKey;
// 创建注册表键项
if(!RegCreateKey(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hKey))
{
CString strKey;
char cSysPath[MAX_PATH];
// 获得当前系统目录
::GetSystemDirectory(cSysPath,MAX_PATH);
// 设置自启动的程序名称
strKey = cSysPath;
strKey += "\\AutoRun.EXE";
// 设置注册表键值为自启动程序名称
RegSetValueEx(hKey,
"AutoRun",
0,
REG_SZ,
(LPBYTE)strKey.GetBuffer(0),
strKey.GetLength()
);
}
}
return nRetCode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -