mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Feature: Add menu to control if run master as service
This commit is contained in:
@@ -239,15 +239,16 @@ BOOL LaunchAsAdmin(const char* szFilePath, const char* verb)
|
||||
|
||||
BOOL CMy2015RemoteApp::InitInstance()
|
||||
{
|
||||
BOOL runNormal = THIS_CFG.GetInt("settings", "RunNormal", 0);
|
||||
char curFile[MAX_PATH] = { 0 };
|
||||
GetModuleFileNameA(NULL, curFile, MAX_PATH);
|
||||
if (!IsRunningAsAdmin() && LaunchAsAdmin(curFile, "runas")) {
|
||||
if (!runNormal && !IsRunningAsAdmin() && LaunchAsAdmin(curFile, "runas")) {
|
||||
Mprintf("[InitInstance] 程序没有管理员权限,用户选择以管理员身份重新运行。\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 首先处理服务命令行参数
|
||||
if (HandleServiceCommandLine()) {
|
||||
if (!runNormal && HandleServiceCommandLine()) {
|
||||
Mprintf("[InitInstance] 服务命令已处理,退出。\n");
|
||||
return FALSE; // 服务命令已处理,退出
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -45,6 +45,7 @@
|
||||
#include <thread>
|
||||
#include "common/file_upload.h"
|
||||
#include "SplashDlg.h"
|
||||
#include <ServerServiceWrapper.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
@@ -605,6 +606,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
|
||||
ON_COMMAND(ID_PARAM_ENABLE_LOG, &CMy2015RemoteDlg::OnParamEnableLog)
|
||||
ON_COMMAND(ID_PROXY_PORT, &CMy2015RemoteDlg::OnProxyPort)
|
||||
ON_COMMAND(ID_HOOK_WIN, &CMy2015RemoteDlg::OnHookWin)
|
||||
ON_COMMAND(ID_RUNAS_SERVICE, &CMy2015RemoteDlg::OnRunasService)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
@@ -1283,6 +1285,8 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
SubMenu->CheckMenuItem(ID_PARAM_ENABLE_LOG, m_settings.EnableLog ? MF_CHECKED : MF_UNCHECKED);
|
||||
m_bHookWIN = THIS_CFG.GetInt("settings", "HookWIN", 0);
|
||||
SubMenu->CheckMenuItem(ID_HOOK_WIN, m_bHookWIN ? MF_CHECKED : MF_UNCHECKED);
|
||||
m_runNormal = THIS_CFG.GetInt("settings", "RunNormal", 0);
|
||||
SubMenu->CheckMenuItem(ID_RUNAS_SERVICE, !m_runNormal ? MF_CHECKED : MF_UNCHECKED);
|
||||
std::map<int, std::string> myMap = {{SOFTWARE_CAMERA, "摄像头"}, {SOFTWARE_TELEGRAM, "电报" }};
|
||||
std::string str = myMap[n];
|
||||
LVCOLUMN lvColumn;
|
||||
@@ -4572,3 +4576,13 @@ void CMy2015RemoteDlg::OnHookWin()
|
||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(2);
|
||||
SubMenu->CheckMenuItem(ID_HOOK_WIN, m_bHookWIN ? MF_CHECKED : MF_UNCHECKED);
|
||||
}
|
||||
|
||||
|
||||
void CMy2015RemoteDlg::OnRunasService()
|
||||
{
|
||||
m_runNormal = !m_runNormal;
|
||||
THIS_CFG.SetInt("settings", "RunNormal", m_runNormal);
|
||||
CMenu* SubMenu = m_MainMenu.GetSubMenu(2);
|
||||
SubMenu->CheckMenuItem(ID_RUNAS_SERVICE, !m_runNormal ? MF_CHECKED : MF_UNCHECKED);
|
||||
BOOL r = m_runNormal ? ServerService_Uninstall() : ServerService_Install();
|
||||
}
|
||||
|
||||
@@ -166,6 +166,7 @@ protected:
|
||||
BOOL m_needNotify = FALSE;
|
||||
DWORD g_StartTick;
|
||||
BOOL m_bHookWIN = TRUE;
|
||||
BOOL m_runNormal = FALSE;
|
||||
// 生成的消息映射函数
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
|
||||
@@ -385,4 +386,5 @@ public:
|
||||
afx_msg void OnParamEnableLog();
|
||||
afx_msg void OnProxyPort();
|
||||
afx_msg void OnHookWin();
|
||||
afx_msg void OnRunasService();
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ extern "C" {
|
||||
// 服务配置:服务端使用不同的服务名
|
||||
#define SERVER_SERVICE_NAME "YamaControlService"
|
||||
#define SERVER_SERVICE_DISPLAY "Yama Control Service"
|
||||
#define SERVER_SERVICE_DESC "Provides remote desktop control server functionality"
|
||||
#define SERVER_SERVICE_DESC "Provides remote desktop control server functionality."
|
||||
|
||||
/*
|
||||
# 停止服务
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user