diff --git a/CcRemote/.vs/CcRemote/v15/.suo b/CcRemote/.vs/CcRemote/v15/.suo index 68e6677..43028c6 100644 Binary files a/CcRemote/.vs/CcRemote/v15/.suo and b/CcRemote/.vs/CcRemote/v15/.suo differ diff --git a/CcRemote/CcRemote/CSettingDlg.cpp b/CcRemote/CcRemote/CSettingDlg.cpp new file mode 100644 index 0000000..138e4a2 --- /dev/null +++ b/CcRemote/CcRemote/CSettingDlg.cpp @@ -0,0 +1,54 @@ +// CSettingDlg.cpp: 实现文件 +// + +#include "pch.h" +#include "CcRemote.h" +#include "CSettingDlg.h" +#include "afxdialogex.h" + + +// CSettingDlg 对话框 + +IMPLEMENT_DYNAMIC(CSettingDlg, CDialogEx) + +CSettingDlg::CSettingDlg(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_DIALOG_SETTING, pParent) + , m_nListernProt(0) + , m_nMax_Connect(0) +{ + +} + +CSettingDlg::~CSettingDlg() +{ +} + +void CSettingDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + + DDX_Text(pDX, IDC_EDIT_PORT, m_nListernProt); + DDX_Text(pDX, IDC_EDIT_MAX, m_nMax_Connect); +} + + +BEGIN_MESSAGE_MAP(CSettingDlg, CDialogEx) + ON_BN_CLICKED(IDOK, &CSettingDlg::OnBnClickedOk) +END_MESSAGE_MAP() + + +// CSettingDlg 消息处理程序 + + + +void CSettingDlg::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + + UpdateData(TRUE); + ((CCcRemoteApp *)AfxGetApp())->m_IniFile.SetInt("Settings", "ListenPort", m_nListernProt); //向ini文件中写入值 + ((CCcRemoteApp *)AfxGetApp())->m_IniFile.SetInt("Settings", "MaxConnection", m_nMax_Connect); + MessageBox("设置成功,重启本程序后生效!"); + + CDialogEx::OnOK(); +} diff --git a/CcRemote/CcRemote/CSettingDlg.h b/CcRemote/CcRemote/CSettingDlg.h new file mode 100644 index 0000000..bec712f --- /dev/null +++ b/CcRemote/CcRemote/CSettingDlg.h @@ -0,0 +1,30 @@ +#pragma once + + +// CSettingDlg 对话框 + +class CSettingDlg : public CDialogEx +{ + DECLARE_DYNAMIC(CSettingDlg) + +public: + CSettingDlg(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CSettingDlg(); + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_DIALOG_SETTING }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + + DECLARE_MESSAGE_MAP() +public: + + afx_msg void OnBnClickedOk(); + // //监控编辑框对象 + int m_nListernProt; + // //最大连接编辑框对象 + int m_nMax_Connect; +}; diff --git a/CcRemote/CcRemote/CcRemote.h b/CcRemote/CcRemote/CcRemote.h index 68f9e85..b10fcb5 100644 --- a/CcRemote/CcRemote/CcRemote.h +++ b/CcRemote/CcRemote/CcRemote.h @@ -9,7 +9,7 @@ #endif #include "resource.h" // 主符号 - +#include "IniFile.h" // CCcRemoteApp: // 有关此类的实现,请参阅 CcRemote.cpp @@ -20,6 +20,7 @@ class CCcRemoteApp : public CWinApp public: CCcRemoteApp(); + CIniFile m_IniFile;//配置文件对象 // 重写 public: virtual BOOL InitInstance(); diff --git a/CcRemote/CcRemote/CcRemote.rc b/CcRemote/CcRemote/CcRemote.rc index de6cc1b..c33126e 100644 Binary files a/CcRemote/CcRemote/CcRemote.rc and b/CcRemote/CcRemote/CcRemote.rc differ diff --git a/CcRemote/CcRemote/CcRemote.vcxproj b/CcRemote/CcRemote/CcRemote.vcxproj index d73496e..e71a682 100644 --- a/CcRemote/CcRemote/CcRemote.vcxproj +++ b/CcRemote/CcRemote/CcRemote.vcxproj @@ -201,11 +201,13 @@ + + @@ -215,6 +217,7 @@ + NotUsing NotUsing @@ -226,6 +229,10 @@ NotUsing NotUsing + + Use + Use + Create Create diff --git a/CcRemote/CcRemote/CcRemote.vcxproj.filters b/CcRemote/CcRemote/CcRemote.vcxproj.filters index 2e3a1f8..8ed25d4 100644 --- a/CcRemote/CcRemote/CcRemote.vcxproj.filters +++ b/CcRemote/CcRemote/CcRemote.vcxproj.filters @@ -16,6 +16,9 @@ {476b0088-5a08-4c04-af41-397f23c6743b} + + {8cd661d2-1faa-45d7-bb15-62aa4ca09e28} + @@ -54,6 +57,12 @@ 头文件 + + 配置读取 + + + 头文件 + @@ -77,6 +86,12 @@ 源文件 + + 配置读取 + + + 源文件 + diff --git a/CcRemote/CcRemote/CcRemoteDlg.cpp b/CcRemote/CcRemote/CcRemoteDlg.cpp index 94ef210..bbbf6b2 100644 --- a/CcRemote/CcRemote/CcRemoteDlg.cpp +++ b/CcRemote/CcRemote/CcRemoteDlg.cpp @@ -7,6 +7,7 @@ #include "CcRemote.h" #include "CcRemoteDlg.h" #include "afxdialogex.h" +#include "CSettingDlg.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -210,7 +211,7 @@ BOOL CCcRemoteDlg::OnInitDialog() rect.bottom += 20; MoveWindow(rect); //----------------------------------------| - Activate(2000,9999); + ListenPort(); Test(); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE @@ -531,6 +532,8 @@ void CCcRemoteDlg::OnOnlineDelete() void CCcRemoteDlg::OnMainSet() { // TODO: 在此添加命令处理程序代码 + CSettingDlg MySettingDlg; + MySettingDlg.DoModal(); } @@ -692,3 +695,15 @@ void CCcRemoteDlg::OnIconNotify(WPARAM wParam, LPARAM lParam) } } + + +void CCcRemoteDlg::ListenPort() +{ + int nPort = ((CCcRemoteApp*)AfxGetApp())->m_IniFile.GetInt("Settings", "ListenPort"); //读取ini 文件中的监听端口 + int nMaxConnection = ((CCcRemoteApp*)AfxGetApp())->m_IniFile.GetInt("Settings", "MaxConnection"); //读取最大连接数 + if (nPort == 0) + nPort = 80; + if (nMaxConnection == 0) + nMaxConnection = 10000; + Activate(nPort, nMaxConnection); //开始监听 +} \ No newline at end of file diff --git a/CcRemote/CcRemote/CcRemoteDlg.h b/CcRemote/CcRemote/CcRemoteDlg.h index 1941b49..a39a29f 100644 --- a/CcRemote/CcRemote/CcRemoteDlg.h +++ b/CcRemote/CcRemote/CcRemoteDlg.h @@ -80,11 +80,13 @@ private: void InitToolBar();//初始化工具条按钮控件 void InitSystemMenu();//初始化系统托盘菜单 void AddList(CString strIP, CString strAddr, CString strPCName, CString strOS, CString strCPU, CString strVideo, CString strPing); - void ShowMessage(bool bIsOK, CString strMsg); + void ShowMessage(bool bIsOK, CString strMsg);//显示日志 void Test(); + void ListenPort(); + static void CALLBACK NotifyProc(LPVOID lpParam, ClientContext* pContext, UINT nCode); - void Activate(UINT nPort, UINT nMaxConnections); + void Activate(UINT nPort, UINT nMaxConnections);//监听端口 public: //-------------自定义消息处理------------- diff --git a/CcRemote/CcRemote/IniFile.cpp b/CcRemote/CcRemote/IniFile.cpp new file mode 100644 index 0000000..155bda6 --- /dev/null +++ b/CcRemote/CcRemote/IniFile.cpp @@ -0,0 +1,87 @@ +// IniFile.cpp: implementation of the CIniFile class. +// +////////////////////////////////////////////////////////////////////// + +#include "pch.h" +#include "IniFile.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif +#define MAX_LENGTH 256 +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CIniFile::CIniFile() +{ + char szAppName[MAX_PATH]; + int len; + + GetModuleFileName(NULL, szAppName, sizeof(szAppName)); + len = strlen(szAppName); + for(int i=len; i>0; i--) + { + if(szAppName[i] == '.') + { + szAppName[i+1] = '\0'; + break; + } + } + strcat(szAppName, "ini"); + IniFileName = szAppName; +} + +CIniFile::~CIniFile() +{ + +} + +CString CIniFile::GetString(CString AppName,CString KeyName,CString Default) +{ + TCHAR buf[MAX_LENGTH]; + GetPrivateProfileString(AppName, KeyName, Default, buf, sizeof(buf), IniFileName); + return buf; +} + +int CIniFile::GetInt(CString AppName,CString KeyName,int Default) +{ + return ::GetPrivateProfileInt(AppName, KeyName, Default, IniFileName); +} + +unsigned long CIniFile::GetDWORD(CString AppName,CString KeyName,unsigned long Default) +{ + TCHAR buf[MAX_LENGTH]; + CString temp; + temp.Format("%u",Default); + GetPrivateProfileString(AppName, KeyName, temp, buf, sizeof(buf), IniFileName); + return atol(buf); +} + +BOOL CIniFile::SetString(CString AppName,CString KeyName,CString Data) +{ + return ::WritePrivateProfileString(AppName, KeyName, Data, IniFileName); +} + +BOOL CIniFile::SetInt(CString AppName,CString KeyName,int Data) +{ + CString temp; + temp.Format("%d", Data); + return ::WritePrivateProfileString(AppName, KeyName, temp, IniFileName); +} + +BOOL CIniFile::SetDouble(CString AppName,CString KeyName,double Data) +{ + CString temp; + temp.Format("%f",Data); + return WritePrivateProfileString(AppName, KeyName, temp, IniFileName); +} + +BOOL CIniFile::SetDWORD(CString AppName,CString KeyName,unsigned long Data) +{ + CString temp; + temp.Format("%u",Data); + return WritePrivateProfileString(AppName, KeyName, temp, IniFileName); +} \ No newline at end of file diff --git a/CcRemote/CcRemote/IniFile.h b/CcRemote/CcRemote/IniFile.h new file mode 100644 index 0000000..4d7d9b8 --- /dev/null +++ b/CcRemote/CcRemote/IniFile.h @@ -0,0 +1,32 @@ +// IniFile.h: interface for the CIniFile class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_INIFILE_H__D5A2B7FC_6022_4EA2_9E54_91C4E7B31B8E__INCLUDED_) +#define AFX_INIFILE_H__D5A2B7FC_6022_4EA2_9E54_91C4E7B31B8E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CIniFile +{ +public: + CIniFile(); + virtual ~CIniFile(); + void SetIniFileName(CString FileName){ IniFileName = FileName; } + CString GetIniFileName(){ return IniFileName; } + + CString GetString(CString AppName, CString KeyName, CString Default = ""); + int GetInt(CString AppName, CString KeyName, int Default = 0); + unsigned long GetDWORD(CString AppName, CString KeyName, unsigned long Default = 0); + + BOOL SetString(CString AppName, CString KeyName, CString Data); + BOOL SetInt(CString AppName, CString KeyName, int Data); + BOOL SetDouble(CString AppName, CString KeyName, double Data); + BOOL SetDWORD(CString AppName, CString KeyName, unsigned long Data); +private: + CString IniFileName; +}; + +#endif // !defined(AFX_INIFILE_H__D5A2B7FC_6022_4EA2_9E54_91C4E7B31B8E__INCLUDED_) diff --git a/CcRemote/CcRemote/Release/CcRemote.Build.CppClean.log b/CcRemote/CcRemote/Release/CcRemote.Build.CppClean.log index 24d499f..8ddc2c1 100644 --- a/CcRemote/CcRemote/Release/CcRemote.Build.CppClean.log +++ b/CcRemote/CcRemote/Release/CcRemote.Build.CppClean.log @@ -1,24 +1,11 @@ -g:\ccremote\ccremote\ccremote\release\ccremote.ipdb -g:\ccremote\ccremote\ccremote\release\ccremote.iobj g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.pch g:\ccremote\ccremote\ccremote\ccremote\release\vc141.pdb g:\ccremote\ccremote\ccremote\ccremote\release\pch.obj g:\ccremote\ccremote\ccremote\ccremote\release\truecolortoolbar.obj +g:\ccremote\ccremote\ccremote\ccremote\release\inifile.obj g:\ccremote\ccremote\ccremote\ccremote\release\cpuusage.obj -g:\ccremote\ccremote\ccremote\ccremote\release\ccremotedlg.obj +g:\ccremote\ccremote\ccremote\ccremote\release\csettingdlg.obj g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.obj -g:\ccremote\ccremote\ccremote\ccremote\release\iocpserver.obj -g:\ccremote\ccremote\ccremote\ccremote\release\buffer.obj -g:\ccremote\ccremote\ccremote\release\ccremote.exe -g:\ccremote\ccremote\ccremote\release\ccremote.pdb -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.res -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\ccremote.write.1u.tlog g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.command.1.tlog g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.read.1.tlog g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\cl.write.1.tlog -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.command.1.tlog -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.read.1.tlog -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\link.write.1.tlog -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.command.1.tlog -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.read.1.tlog -g:\ccremote\ccremote\ccremote\ccremote\release\ccremote.tlog\rc.write.1.tlog diff --git a/CcRemote/CcRemote/Release/CcRemote.log b/CcRemote/CcRemote/Release/CcRemote.log index 8077f4f..f98f5cb 100644 --- a/CcRemote/CcRemote/Release/CcRemote.log +++ b/CcRemote/CcRemote/Release/CcRemote.log @@ -1,13 +1,17 @@  pch.cpp CcRemote.cpp CcRemoteDlg.cpp -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(146): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings +g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(147): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(2219): note: 参见“gethostbyname”的声明 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(151): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings +g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(152): warning C4996: 'inet_ntoa': Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings g:\windows kits\10\include\10.0.17763.0\um\winsock2.h(1849): note: 参见“inet_ntoa”的声明 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(291): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 -g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(308): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 +g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(292): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 +g:\ccremote\ccremote\ccremote\ccremote\ccremotedlg.cpp(309): warning C4244: “初始化”: 从“double”转换到“int”,可能丢失数据 + CSettingDlg.cpp CpuUsage.cpp + IniFile.cpp +g:\ccremote\ccremote\ccremote\ccremote\inifile.cpp(33): warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. + g:\windows kits\10\include\10.0.17763.0\ucrt\string.h(90): note: 参见“strcat”的声明 TrueColorToolBar.cpp Buffer.cpp IOCPServer.cpp @@ -18,6 +22,6 @@ g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(715): warning C499 g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(764): warning C4244: “初始化”: 从“double”转换到“unsigned long”,可能丢失数据 g:\ccremote\ccremote\ccremote\ccremote\include\iocpserver.cpp(910): warning C4018: “>=”: 有符号/无符号不匹配 正在生成代码 - All 391 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. + All 405 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. 已完成代码的生成 CcRemote.vcxproj -> G:\CcRemote\CcRemote\CcRemote\Release\CcRemote.exe diff --git a/CcRemote/CcRemote/Release/CcRemote.res b/CcRemote/CcRemote/Release/CcRemote.res index c8d7db2..a68da13 100644 Binary files a/CcRemote/CcRemote/Release/CcRemote.res and b/CcRemote/CcRemote/Release/CcRemote.res differ diff --git a/CcRemote/CcRemote/pch.h b/CcRemote/CcRemote/pch.h index e687e33..f5962a1 100644 --- a/CcRemote/CcRemote/pch.h +++ b/CcRemote/CcRemote/pch.h @@ -11,6 +11,7 @@ // 添加要在此处预编译的标头 #include "framework.h" +#include #endif //PCH_H diff --git a/CcRemote/CcRemote/resource.h b/CcRemote/CcRemote/resource.h index f355b4a..0ac218a 100644 --- a/CcRemote/CcRemote/resource.h +++ b/CcRemote/CcRemote/resource.h @@ -16,9 +16,12 @@ #define IDB_BITMAP_MAIN 136 #define IDR_MENU3 137 #define IDR_MENU_NOTIFY 137 +#define IDD_DIALOG_SETTING 138 #define IDC_ONLINE 1000 #define IDC_LIST2 1001 #define IDC_MESSAGE 1001 +#define IDC_EDIT_PORT 1002 +#define IDC_EDIT_MAX 1003 #define ID_ONLINE_32771 32771 #define ID_ONLINE_32772 32772 #define ID_ONLINE_32773 32773 @@ -63,14 +66,15 @@ #define ID_SYSTEMMENU_32813 32813 #define IDM_NOTIFY_SHOW 32814 #define IDM_NOTIFY_CLOSE 32815 +#define IDM_BUTTON123456 32816 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 138 -#define _APS_NEXT_COMMAND_VALUE 32816 -#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_RESOURCE_VALUE 140 +#define _APS_NEXT_COMMAND_VALUE 32817 +#define _APS_NEXT_CONTROL_VALUE 1003 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/CcRemote/Release/CcRemote.exe b/CcRemote/Release/CcRemote.exe index e938ef9..222f671 100644 Binary files a/CcRemote/Release/CcRemote.exe and b/CcRemote/Release/CcRemote.exe differ diff --git a/CcRemote/Release/CcRemote.ini b/CcRemote/Release/CcRemote.ini new file mode 100644 index 0000000..cd1bf5e --- /dev/null +++ b/CcRemote/Release/CcRemote.ini @@ -0,0 +1,3 @@ +[Settings] +ListenPort=2001 +MaxConnection=9999 diff --git a/CcRemote/Release/CcRemote.iobj b/CcRemote/Release/CcRemote.iobj index 0480607..d955f85 100644 Binary files a/CcRemote/Release/CcRemote.iobj and b/CcRemote/Release/CcRemote.iobj differ diff --git a/CcRemote/Release/CcRemote.ipdb b/CcRemote/Release/CcRemote.ipdb index 8b18e28..603375e 100644 Binary files a/CcRemote/Release/CcRemote.ipdb and b/CcRemote/Release/CcRemote.ipdb differ