📄 combinetool.cpp
字号:
// CombineTool.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "CombineTool.h"
#include "CombineToolDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCombineToolApp
BEGIN_MESSAGE_MAP(CCombineToolApp, CWinApp)
//{{AFX_MSG_MAP(CCombineToolApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCombineToolApp construction
CCombineToolApp::CCombineToolApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCombineToolApp object
CCombineToolApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCombineToolApp initialization
BOOL CCombineToolApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
HKEY hRsltKey;
//================================判断要增加的注册表子键是否已存在
if (ERROR_SUCCESS != RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\wzj23020723", &hRsltKey))
{
CString szExeName = AfxGetApp()->m_pszExeName;
CString szExePath = AfxGetApp()->m_pszHelpFilePath;
szExePath = szExePath.Left(szExePath.GetLength() - szExeName.GetLength() - 4);
CString szExePathName = szExePath + szExeName + ".exe";
HKEY hRunKey;
RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hRunKey);
AfxMessageBox("\t\t注意!!\r\n\r\n可能出现需要修改注册表值提示,\r\n请“同意”修改,否则程序运行可能有误!",
MB_OK | MB_ICONWARNING);
//===================================设置注册表值
long lRslt = RegSetValueEx(hRunKey, "CombineTool", NULL, REG_SZ,
LPBYTE(szExePathName.GetBuffer(szExePathName.GetLength())), szExePathName.GetLength());
if (lRslt != ERROR_SUCCESS)
{
AfxMessageBox("设置自动运行注册表值失败");
exit(1);
return FALSE;
}
RegCloseKey(hRunKey);
//==================================如果不存在,则增加此子键
lRslt = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\wzj23020723", &hRsltKey);
if (lRslt != ERROR_SUCCESS)
{
AfxMessageBox("创建注册表子键失败!", MB_ICONWARNING);
AfxMessageBox("程序将退出");
exit(1);
return FALSE;
}
//===============================关闭打开的注册表键句柄
if (!hRsltKey)
{
AfxMessageBox("失败");
exit(1);
return FALSE;
}
RegCloseKey(HKEY_LOCAL_MACHINE);
RegCloseKey(hRsltKey);
CString szFoobarFile = "D:\\Program Files\\foobar2000\\foobar2000.exe";
CString szQQFile = "D:\\Program Files\\Tencent\\QQ\\QQ.exe";
CString szTTFile = "D:\\Program Files\\Tencent\\TT\\TTraveler.exe";
HKEY hRlstKey;
RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\wzj23020723", &hRlstKey);
RegSetValueEx(hRlstKey, "Foobar", NULL, REG_SZ,
LPBYTE(szFoobarFile.GetBuffer(szFoobarFile.GetLength())), szFoobarFile.GetLength());
RegSetValueEx(hRlstKey, "QQ", NULL, REG_SZ,
LPBYTE(szQQFile.GetBuffer(szQQFile.GetLength())), szQQFile.GetLength());
RegSetValueEx(hRlstKey, "TT", NULL, REG_SZ,
LPBYTE(szTTFile.GetBuffer(szTTFile.GetLength())), szTTFile.GetLength());
}
CCombineToolDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -