Init: Migrate SimpleRemoter (Since v1.3.1) to Gitea
This commit is contained in:
141
server/2015Remote/CRcEditDlg.cpp
Normal file
141
server/2015Remote/CRcEditDlg.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
// CRcEditDlg.cpp: 实现文件
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "CRcEditDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "Resource.h"
|
||||
|
||||
|
||||
// CRcEditDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CRcEditDlg, CDialogEx)
|
||||
|
||||
CRcEditDlg::CRcEditDlg(CWnd* pParent /*=nullptr*/)
|
||||
: CDialogLangEx(IDD_DIALOG_RCEDIT, pParent)
|
||||
, m_sExePath(_T(""))
|
||||
, m_sIcoPath(_T(""))
|
||||
, m_sProcessDesc(_T(""))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CRcEditDlg::~CRcEditDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CRcEditDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
__super::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_EDIT_EXE_FILE, m_EditExe);
|
||||
DDX_Control(pDX, IDC_EDIT_ICO_FILE, m_EditIco);
|
||||
DDX_Text(pDX, IDC_EDIT_EXE_FILE, m_sExePath);
|
||||
DDV_MaxChars(pDX, m_sExePath, 256);
|
||||
DDX_Text(pDX, IDC_EDIT_ICO_FILE, m_sIcoPath);
|
||||
DDV_MaxChars(pDX, m_sIcoPath, 256);
|
||||
DDX_Control(pDX, IDC_EDIT_PROCESS_DESC, m_EditProcessDesc);
|
||||
DDX_Text(pDX, IDC_EDIT_PROCESS_DESC, m_sProcessDesc);
|
||||
DDV_MaxChars(pDX, m_sProcessDesc, 135);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CRcEditDlg, CDialogEx)
|
||||
ON_BN_CLICKED(IDC_BTN_SELECT_EXE, &CRcEditDlg::OnBnClickedBtnSelectExe)
|
||||
ON_BN_CLICKED(IDC_BTN_SELECT_ICO, &CRcEditDlg::OnBnClickedBtnSelectIco)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CRcEditDlg 消息处理程序
|
||||
|
||||
|
||||
BOOL CRcEditDlg::OnInitDialog()
|
||||
{
|
||||
__super::OnInitDialog();
|
||||
// 多语言翻译 - Static控件
|
||||
SetDlgItemText(IDC_STATIC_RCEDIT_TIP, _TR("提示: 替换完成后,请刷新程序进行查看;如若未成功,请更换图标重试。"));
|
||||
SetDlgItemText(IDC_STATIC_RCEDIT_DESC, _TR("进程描述:"));
|
||||
|
||||
// 设置对话框标题和控件文本(解决英语系统乱码问题)
|
||||
SetWindowText(_TR("PE 编辑"));
|
||||
SetDlgItemText(IDC_BTN_SELECT_EXE, _TR("目标程序"));
|
||||
SetDlgItemText(IDC_BTN_SELECT_ICO, _TR("图标文件"));
|
||||
SetDlgItemText(IDOK, _TR("确定"));
|
||||
SetDlgItemText(IDCANCEL, _TR("取消"));
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// 异常: OCX 属性页应返回 FALSE
|
||||
}
|
||||
|
||||
|
||||
void CRcEditDlg::OnOK()
|
||||
{
|
||||
if (m_sExePath.IsEmpty()) {
|
||||
MessageBoxL("请选择目标应用程序!", "提示", MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
m_EditProcessDesc.GetWindowTextA(m_sProcessDesc);
|
||||
if (m_sIcoPath.IsEmpty() && m_sProcessDesc.IsEmpty()) {
|
||||
MessageBoxL("请选择[*.ico]图标文件或输入进程描述!", "提示", MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
std::string ReleaseEXE(int resID, const char* name);
|
||||
int run_cmd(std::string cmdLine);
|
||||
|
||||
std::string rcedit = ReleaseEXE(IDR_BIN_RCEDIT, "rcedit.exe");
|
||||
if (rcedit.empty()) {
|
||||
MessageBoxL("解压程序失败,无法操作PE!", "提示", MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
std::string exe = m_sExePath.GetString();
|
||||
std::string icon = m_sIcoPath.GetString();
|
||||
std::string desc = m_sProcessDesc.GetString();
|
||||
std::string cmdLine = "\"" + rcedit + "\" \"" + exe + "\"";
|
||||
if (!icon.empty())
|
||||
cmdLine += " --set-icon \"" + icon + "\"";
|
||||
if (!desc.empty())
|
||||
cmdLine += " --set-version-string \"FileDescription\" \"" + desc + "\"";
|
||||
int result = run_cmd(cmdLine);
|
||||
if (result) {
|
||||
MessageBoxL(_TR("PE 操作失败,错误代码: ") + std::to_string(result).c_str(),
|
||||
"提示", MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
|
||||
__super::OnOK();
|
||||
}
|
||||
|
||||
|
||||
void CRcEditDlg::OnBnClickedBtnSelectExe()
|
||||
{
|
||||
CFileDialog fileDlg(TRUE, _T("exe"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||
_T("EXE Files (*.exe)|*.exe|All Files (*.*)|*.*||"), AfxGetMainWnd());
|
||||
int ret = 0;
|
||||
try {
|
||||
ret = fileDlg.DoModal();
|
||||
} catch (...) {
|
||||
MessageBoxL("文件对话框未成功打开! 请稍后再试。", "提示", MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
if (ret == IDOK) {
|
||||
m_sExePath = fileDlg.GetPathName();
|
||||
m_EditExe.SetWindowTextA(m_sExePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRcEditDlg::OnBnClickedBtnSelectIco()
|
||||
{
|
||||
CFileDialog fileDlg(TRUE, _T("ico"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||||
_T("ICO Files (*.ico)|*.ico|All Files (*.*)|*.*||"), AfxGetMainWnd());
|
||||
int ret = 0;
|
||||
try {
|
||||
ret = fileDlg.DoModal();
|
||||
} catch (...) {
|
||||
MessageBoxL("文件对话框未成功打开! 请稍后再试。", "提示", MB_ICONINFORMATION);
|
||||
return;
|
||||
}
|
||||
if (ret == IDOK) {
|
||||
m_sIcoPath = fileDlg.GetPathName();
|
||||
m_EditIco.SetWindowTextA(m_sIcoPath);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user