📄 unicodedlg.cpp
字号:
// unicodeDlg.cpp : implementation file
//
#include "stdAfx.h"
#include "unicode.h"
#include "unicodeDlg.h"
#include "ClientSockThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//extern UINT ClientSocketThreadProc(LPVOID);
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
CHyperLink m_sUrl;
// 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)
virtual BOOL OnInitDialog();
//}}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)
// DDX_Control(pDX, IDC_STATIC1, m_sUrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUnicodeDlg dialog
//extern HWND hwnd;
CUnicodeDlg::CUnicodeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUnicodeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUnicodeDlg)
m_startip = _T("127.0.0.1");
m_endip = _T("127.0.0.1");
m_pDaodb=new CDaoDatabase;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CUnicodeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUnicodeDlg)
// DDX_Control(pDX, IDC_RESULT, m_result);
DDX_Control(pDX, IDC_ANIMATE1, m_ani1);
DDX_Text(pDX, IDC_EDIT1, m_startip);
DDX_Text(pDX, IDC_EDIT2, m_endip);
DDX_Control(pDX, IDC_STATIC1, m_stcURL);
DDX_Control(pDX, IDC_STATIC2, m_stcURL1);
DDX_Control(pDX, IDC_EDIT1, m_Edit1);
DDX_Control(pDX, IDC_EDIT2, m_Edit2);
DDX_Control(pDX, IDOK, btn1);
DDX_Control(pDX, IDOK2, btn2);
DDX_Control(pDX, IDCANCEL, btn3);
DDX_Control(pDX, IDCLEAR, btn4);
DDX_Control(pDX, IDC_RESULT, m_result);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUnicodeDlg, CDialog)
//{{AFX_MSG_MAP(CUnicodeDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_BN_CLICKED(IDOK2, OnStop)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDCLEAR, OnClear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUnicodeDlg message handlers
BOOL CUnicodeDlg::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
WSADATA wsd;
WORD wWinSockVer;
wWinSockVer=MAKEWORD(2,0);
int err=WSAStartup(wWinSockVer, &wsd);
if(err!=0)
{
AfxMessageBox("WINSOCK 版本无效!");
return FALSE;
}
BYTE btLowVer=LOBYTE(wsd.wVersion);
//如果SOCK的版本大于2.0
if(LOBYTE(wsd.wVersion)<2)
{
AfxMessageBox("WINSOCK 版本无效!");
WSACleanup();
return FALSE;
}
m_stcURL.SetWindowText("http://www.wantsoft.com");
m_stcURL.SetAutoSize(FALSE);
m_stcURL.SetURL("http://www.wantsoft.com");
m_stcURL.SetColours(RGB(0,0,255), RGB(0,0,0) ,RGB(255,0,0));
m_stcURL1.SetWindowText("mailto:webants@163.com");
m_stcURL1.SetAutoSize(FALSE);
m_stcURL1.SetURL("mailto:webants@163.com");
m_stcURL1.SetColours(RGB(0,0,255), RGB(0,0,0) ,RGB(255,0,0));
btn1.SetButtonText("开始扫描");
btn2.SetButtonText("停止扫描");
btn3.SetButtonText("退出程序");
btn4.SetButtonText("清空列表");
m_result.AddString(" 欢迎使用思想软件安全扫描工具");
m_result.AddString("台湾自古以来是中国的领土");
m_result.AddString("版权所有,翻版必究!Copyright (c) by suyu 2001");
m_result.AddString("HTTP://WWW.WANTSOFT.COM");
m_result.AddString("QQ:65604295");
TCHAR szBuffer[256];
DWORD dwSize=256;
GetCurrentDirectory(dwSize,szBuffer);
hwnd=GetSafeHwnd();
CString strTemp;
strTemp=szBuffer;
m_ani1.Open(IDR_AVI);
m_ani1.Stop();
return TRUE; // return TRUE unless you set the focus to a control
}
void CUnicodeDlg::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 CUnicodeDlg::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 CUnicodeDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CUnicodeDlg::ValidAddress(CString sAddress,
UINT& n1,
UINT& n2,
UINT& n3,
UINT& n4)
{
int nPos;
CString sTemp=sAddress;
n1=atoi(sTemp);
nPos=sTemp.Find(".");
if(nPos==-1) return false;
sTemp=sTemp.Mid(nPos+1);
n2=atoi(sTemp);
nPos=sTemp.Find(".");
if(nPos==-1) return false;
sTemp=sTemp.Mid(nPos+1);
n3=atoi(sTemp);
nPos=sTemp.Find(".");
if(nPos==-1) return false;
sTemp=sTemp.Mid(nPos+1);
n4=atoi(sTemp);
if(n1<0 ||n1>255) return false;
if(n2<0 ||n2>255) return false;
if(n3<0 ||n3>255) return false;
if(n4<0 ||n4>255) return false;
return true;
}
void CUnicodeDlg::OnOK()
{
UINT nStartAddr1,nStartAddr2,nStartAddr3,nStartAddr4;
UINT nEndAddr1,nEndAddr2,nEndAddr3,nEndAddr4;
UpdateData(true);
if (!ValidAddress(m_startip,
nStartAddr1,
nStartAddr2,
nStartAddr3,
nStartAddr4))
{
CString sInvalidAddr=m_startip + "\r\nIP地址格式不正确。";
sInvalidAddr+="请输入n.n.n.n格式地址。";
MessageBox(sInvalidAddr,"无效地址",MB_ICONEXCLAMATION);
GetDlgItem(IDC_EDIT1)->SetFocus();
return;
}
if (!ValidAddress(m_endip,
nEndAddr1,
nEndAddr2,
nEndAddr3,
nEndAddr4))
{
CString sInvalidAddr=m_endip+"\r\nIP地址格式不正确。";
sInvalidAddr+="请输入n.n.n.n格式地址。";
MessageBox(sInvalidAddr,"无效地址",MB_ICONEXCLAMATION);
GetDlgItem(IDC_EDIT2)->SetFocus();
return;
}
unsigned long nStartVal=(nStartAddr1<<24)+
(nStartAddr2<<16)+
(nStartAddr3<<8)+
(nStartAddr4);
unsigned long nEndVal=(nEndAddr1<<24)+
(nEndAddr2<<16)+
(nEndAddr3<<8)+
(nEndAddr4);
if (nEndVal<nStartVal)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -