📄 queryipdlg.cpp
字号:
// QueryipDlg.cpp : implementation file
//
#include "stdafx.h"
#include "queryip.h"
#include "QueryipDlg.h"
#include <nb30.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CQueryipDlg dialog
struct WSAData
{WORD wVersion;
WORD wHighVersion;
char szDescription[255];
char szSystemStatus[255];
unsigned short iMaxSockets;
unsigned short iMaxUdpDg;
char FAR* IpVendorInfo;
};
struct hostent
{
char FAR* h_name;
char FAR* FAR* h_aliases;
short h_addrtype;
short h_length;
char FAR* FAR* h_addr_list;
};
struct hostent FAR *PASCAL FAR gethostbyaddr(const char FAR *addr,int len,int type);
CQueryipDlg::CQueryipDlg(CWnd* pParent /*=NULL*/)
: CDialog(CQueryipDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CQueryipDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CQueryipDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CQueryipDlg)
DDX_Control(pDX, IDC_LIST1, m_List);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CQueryipDlg, CDialog)
//{{AFX_MSG_MAP(CQueryipDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnQueryip)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQueryipDlg message handlers
void CQueryipDlg::OnQueryip()
{
// TODO: Add your control notification handler code here
int i;
WSAData wsaData;
DWORD Addr;
char ip_temp1[15];
char ip_temp2[3];
WSAStartuprtup(MAKEWORD(1,1),&wsaData);
for(i=1;i<255;i++)
{
strcpy(ip_temp1,"192.168.1.");
_itoa(i,ip_temp2,10);
strcat(ip_temp1,ip_temp2);
Addr=inet_addr(ip_temp1);
if(gethostbyaddr((char*)&Addr,sizeof(Addr),PF_INET))
m_List.AddString(ip_temp1);
}
WSACleanup();
}
void CQueryipDlg::OnSelchangeList1()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -