📄 testnetdlg.h
字号:
/*
* Openmysee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#pragma once
#include "afxwin.h"
#include <Winsock2.h>
// CTestNetDlg dialog
enum CONNECT_RESULT {CR_ERROR, CR_CONNECTED, CR_WOULDBLOCK};
class CTestNetDlg : public CDialog
{
DECLARE_DYNAMIC(CTestNetDlg)
public:
CTestNetDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CTestNetDlg();
// Dialog Data
enum { IDD = IDD_TEST_NET };
public:
//得到当前的SpAddress,在实例化之前调
void GetAddr(CString astrSPAddress);
//与网络相关的函数
private:
//得到IP地址
SOCKADDR_IN GetCurAddrin(CString astrIPAddr);
//初始化WinSock
int InitSock();
//反初始化WinSock
void UnInitSock();
//开始连接
CONNECT_RESULT Connecting(SOCKET& asocket, CString astrIPAddr);
//断开连接
void Disconnect(SOCKET& asocket);
//测试网络
BOOL TestNet(CString astrCurIP);
//线程函数
static void WINAPI ConnectProc(CTestNetDlg* apTestNetDlg);
//得到多线结果
void GetResult();
//显示多线结果
void DisplayResult();
private:
struct STRU_CONNECT
{
BOOL mbResult; //连接的结果
SOCKET msocket; //连接的套接字
CString mstrIP; //连接的IP
};
CStringArray mStrAryIPAry; //测试的IP
CComboBox mcomboxIPAry; //测试IP的ComboBox
CString mstrState; // 测试的状态
STRU_CONNECT* mpstruConnect;
CRITICAL_SECTION moCriticalSection; //临界区
int minum; //使用的序号
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedTest();
afx_msg void OnBnClickedBtnTestAll();
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -