2019-01-05 20:21:43 +08:00
|
|
|
|
// ServicesDlg.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "2015Remote.h"
|
|
|
|
|
|
#include "ServicesDlg.h"
|
|
|
|
|
|
#include "afxdialogex.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CServicesDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CServicesDlg, CDialog)
|
|
|
|
|
|
|
2025-01-12 03:39:54 +08:00
|
|
|
|
// ItemData1 <20><>Ҫ<EFBFBD><D2AA>ItemDataͬ<61><CDAC><EFBFBD>ˣ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-10-15 04:32:59 +08:00
|
|
|
|
typedef struct ItemData1 {
|
|
|
|
|
|
CString Data[5];
|
|
|
|
|
|
CString GetData(int index) const
|
|
|
|
|
|
{
|
|
|
|
|
|
return this ? Data[index] : "";
|
|
|
|
|
|
}
|
2025-01-12 03:39:54 +08:00
|
|
|
|
} ItemData1;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
2025-06-29 21:25:59 +08:00
|
|
|
|
CServicesDlg::CServicesDlg(CWnd* pParent, Server* IOCPServer, CONTEXT_OBJECT *ContextObject)
|
2025-10-15 04:32:59 +08:00
|
|
|
|
: DialogBase(CServicesDlg::IDD, pParent, IOCPServer, ContextObject, IDI_SERVICE)
|
2019-01-05 20:21:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CServicesDlg::~CServicesDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
|
|
|
DDX_Control(pDX, IDC_LIST, m_ControlList);
|
|
|
|
|
|
DDX_Control(pDX, IDC_STATIC_COUNT, m_ServicesCount);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CServicesDlg, CDialog)
|
2025-10-15 04:32:59 +08:00
|
|
|
|
ON_WM_CLOSE()
|
|
|
|
|
|
ON_WM_SIZE()
|
|
|
|
|
|
ON_COMMAND(ID_SERVICES_AUTO, &CServicesDlg::OnServicesAuto)
|
|
|
|
|
|
ON_COMMAND(ID_SERVICES_MANUAL, &CServicesDlg::OnServicesManual)
|
|
|
|
|
|
ON_COMMAND(ID_SERVICES_STOP, &CServicesDlg::OnServicesStop)
|
|
|
|
|
|
ON_COMMAND(ID_SERVICES_START, &CServicesDlg::OnServicesStart)
|
|
|
|
|
|
ON_COMMAND(ID_SERVICES_REFLASH, &CServicesDlg::OnServicesReflash)
|
|
|
|
|
|
ON_NOTIFY(NM_RCLICK, IDC_LIST, &CServicesDlg::OnNMRClickList)
|
|
|
|
|
|
ON_NOTIFY(HDN_ITEMCLICK, 0, &CServicesDlg::OnHdnItemclickList)
|
2019-01-05 20:21:43 +08:00
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CServicesDlg <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL CServicesDlg::OnInitDialog()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
|
|
|
|
|
|
SetIcon(m_hIcon, TRUE);
|
|
|
|
|
|
SetIcon(m_hIcon, FALSE);
|
|
|
|
|
|
CString strString;
|
|
|
|
|
|
strString.Format("%s - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",m_IPAddress);
|
|
|
|
|
|
SetWindowText(strString);
|
|
|
|
|
|
|
|
|
|
|
|
m_ControlList.SetExtendedStyle( LVS_EX_FULLROWSELECT);
|
|
|
|
|
|
m_ControlList.InsertColumn(0, "<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 150);
|
|
|
|
|
|
m_ControlList.InsertColumn(1, "<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 260);
|
|
|
|
|
|
m_ControlList.InsertColumn(2, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 80);
|
|
|
|
|
|
m_ControlList.InsertColumn(3, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬", LVCFMT_LEFT, 80);
|
|
|
|
|
|
m_ControlList.InsertColumn(4, "<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>", LVCFMT_LEFT, 380);
|
|
|
|
|
|
|
|
|
|
|
|
ShowServicesList();
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
|
|
|
|
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CServicesDlg::ShowServicesList(void)
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
Buffer tmp = m_ContextObject->InDeCompressedBuffer.GetMyBuffer(1);
|
|
|
|
|
|
char *szBuffer = tmp.c_str();
|
|
|
|
|
|
char *szDisplayName;
|
|
|
|
|
|
char *szServiceName;
|
|
|
|
|
|
char *szRunWay;
|
|
|
|
|
|
char *szAutoRun;
|
|
|
|
|
|
char *szFilePath;
|
|
|
|
|
|
DWORD dwOffset = 0;
|
|
|
|
|
|
DeleteAllItems();
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
for (i = 0; dwOffset < m_ContextObject->InDeCompressedBuffer.GetBufferLength() - 1; ++i) {
|
|
|
|
|
|
szDisplayName = szBuffer + dwOffset;
|
|
|
|
|
|
szServiceName = szDisplayName + lstrlen(szDisplayName) +1;
|
|
|
|
|
|
szFilePath= szServiceName + lstrlen(szServiceName) +1;
|
|
|
|
|
|
szRunWay = szFilePath + lstrlen(szFilePath) + 1;
|
|
|
|
|
|
szAutoRun = szRunWay + lstrlen(szRunWay) + 1;
|
|
|
|
|
|
|
|
|
|
|
|
m_ControlList.InsertItem(i, szServiceName);
|
|
|
|
|
|
m_ControlList.SetItemText(i, 1, szDisplayName);
|
|
|
|
|
|
m_ControlList.SetItemText(i, 2, szAutoRun);
|
|
|
|
|
|
m_ControlList.SetItemText(i, 3, szRunWay);
|
|
|
|
|
|
m_ControlList.SetItemText(i, 4, szFilePath );
|
|
|
|
|
|
auto data = new ItemData1{ szServiceName, szDisplayName, szAutoRun, szRunWay, szFilePath };
|
|
|
|
|
|
m_ControlList.SetItemData(i, (DWORD_PTR)data);
|
|
|
|
|
|
dwOffset += lstrlen(szDisplayName) + lstrlen(szServiceName) + lstrlen(szFilePath) + lstrlen(szRunWay)
|
|
|
|
|
|
+ lstrlen(szAutoRun) +5;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CString strTemp;
|
|
|
|
|
|
strTemp.Format("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d",i);
|
|
|
|
|
|
|
|
|
|
|
|
m_ServicesCount.SetWindowText(strTemp);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnClose()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
CancelIO();
|
|
|
|
|
|
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
if (IsProcessing()) {
|
|
|
|
|
|
ShowWindow(SW_HIDE);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-06-29 03:29:35 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
DeleteAllItems();
|
2025-06-28 23:52:26 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
DialogBase::OnClose();
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnServicesAuto()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
ServicesConfig(3);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnServicesManual()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
ServicesConfig(4);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnServicesStop()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
ServicesConfig(2);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnServicesStart()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
ServicesConfig(1);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnServicesReflash()
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
BYTE bToken = COMMAND_SERVICELIST; //ˢ<><CBA2>
|
|
|
|
|
|
m_ContextObject->Send2Client(&bToken, 1);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-12 03:39:54 +08:00
|
|
|
|
// <20>ͷ<EFBFBD><CDB7><EFBFBD>Դ<EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-10-15 04:32:59 +08:00
|
|
|
|
void CServicesDlg::DeleteAllItems()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < m_ControlList.GetItemCount(); i++) {
|
|
|
|
|
|
auto data = (ItemData1*)m_ControlList.GetItemData(i);
|
|
|
|
|
|
if (NULL != data) {
|
|
|
|
|
|
delete data;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
m_ControlList.DeleteAllItems();
|
2025-01-12 03:39:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
int CALLBACK CServicesDlg::CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto* pSortInfo = reinterpret_cast<std::pair<int, bool>*>(lParamSort);
|
|
|
|
|
|
int nColumn = pSortInfo->first;
|
|
|
|
|
|
bool bAscending = pSortInfo->second;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ֵ
|
|
|
|
|
|
ItemData1* context1 = (ItemData1*)lParam1;
|
|
|
|
|
|
ItemData1* context2 = (ItemData1*)lParam2;
|
|
|
|
|
|
CString s1 = context1->GetData(nColumn);
|
|
|
|
|
|
CString s2 = context2->GetData(nColumn);
|
|
|
|
|
|
|
|
|
|
|
|
int result = s1 > s2 ? 1 : -1;
|
|
|
|
|
|
return bAscending ? result : -result;
|
2025-01-12 03:39:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
void CServicesDlg::SortByColumn(int nColumn)
|
|
|
|
|
|
{
|
|
|
|
|
|
static int m_nSortColumn = 0;
|
|
|
|
|
|
static bool m_bSortAscending = false;
|
|
|
|
|
|
if (nColumn == m_nSortColumn) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<CDAC>У<EFBFBD><D0A3>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|
|
|
|
|
m_bSortAscending = !m_bSortAscending;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|
|
|
|
|
m_nSortColumn = nColumn;
|
|
|
|
|
|
m_bSortAscending = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
std::pair<int, bool> sortInfo(m_nSortColumn, m_bSortAscending);
|
|
|
|
|
|
m_ControlList.SortItems(CompareFunction, reinterpret_cast<LPARAM>(&sortInfo));
|
2025-01-12 03:39:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
void CServicesDlg::OnHdnItemclickList(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
|
{
|
|
|
|
|
|
LPNMHEADER pNMHeader = reinterpret_cast<LPNMHEADER>(pNMHDR);
|
|
|
|
|
|
int nColumn = pNMHeader->iItem; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
SortByColumn(nColumn); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*pResult = 0;
|
2025-01-12 03:39:54 +08:00
|
|
|
|
}
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult)
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
|
|
|
|
|
|
|
|
|
|
CMenu Menu;
|
|
|
|
|
|
Menu.LoadMenu(IDR_MENU_SERVICES);
|
|
|
|
|
|
CMenu *SubMenu=Menu.GetSubMenu(0);
|
|
|
|
|
|
CPoint Point;
|
|
|
|
|
|
GetCursorPos(&Point);
|
|
|
|
|
|
SubMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,Point.x,Point.y,this);
|
|
|
|
|
|
*pResult = 0;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnReceiveComplete(void)
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
switch (m_ContextObject->InDeCompressedBuffer.GetBYTE(0)) {
|
|
|
|
|
|
case TOKEN_SERVERLIST:
|
|
|
|
|
|
ShowServicesList();
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
// <20><><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::ServicesConfig(BYTE bCmd)
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
DWORD dwOffset = 2;
|
|
|
|
|
|
POSITION Pos = m_ControlList.GetFirstSelectedItemPosition();
|
|
|
|
|
|
int iItem = m_ControlList.GetNextSelectedItem(Pos);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
CString strServicesName = m_ControlList.GetItemText(iItem, 0 );
|
|
|
|
|
|
char* szServiceName = strServicesName.GetBuffer(0);
|
|
|
|
|
|
LPBYTE szBuffer = (LPBYTE)LocalAlloc(LPTR, 3 + lstrlen(szServiceName)); //[][][]\0
|
|
|
|
|
|
szBuffer[0] = COMMAND_SERVICECONFIG;
|
|
|
|
|
|
szBuffer[1] = bCmd;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
memcpy(szBuffer + dwOffset, szServiceName, lstrlen(szServiceName)+1);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
m_ContextObject->Send2Client(szBuffer, LocalSize(szBuffer));
|
|
|
|
|
|
LocalFree(szBuffer);
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
2025-06-28 23:52:26 +08:00
|
|
|
|
|
|
|
|
|
|
void CServicesDlg::OnSize(UINT nType, int cx, int cy)
|
|
|
|
|
|
{
|
2025-10-15 04:32:59 +08:00
|
|
|
|
CDialog::OnSize(nType, cx, cy);
|
2025-06-28 23:52:26 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
if (!m_ControlList.GetSafeHwnd()) return; // ȷ<><C8B7><EFBFBD>ؼ<EFBFBD><D8BC>Ѵ<EFBFBD><D1B4><EFBFBD>
|
2025-06-28 23:52:26 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>úʹ<C3BA>С
|
|
|
|
|
|
CRect rc;
|
|
|
|
|
|
m_ControlList.GetWindowRect(&rc);
|
|
|
|
|
|
ScreenToClient(&rc);
|
2025-06-28 23:52:26 +08:00
|
|
|
|
|
2025-10-15 04:32:59 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD>С
|
|
|
|
|
|
m_ControlList.MoveWindow(0, 0, cx, cy, TRUE);
|
2025-06-28 23:52:26 +08:00
|
|
|
|
}
|