网络安全设计局域网主机扫描内容摘要:

) { CDialog::OnInitDialog()。 // Set the icon for this dialog. The framework does this automatically // when the application39。 s main window is not a dialog SetIcon(m_hIcon, TRUE)。 // Set big icon SetIcon(m_hIcon, FALSE)。 // Set small icon // TODO: Add extra initialization here (192,168,0,1)。 //设置 ip 地址默认范围 (192,168,0,255)。 wait_handle=CreateEvent(NULL,true,false,receive data)。 //创建处于非触发状态的事件。 类型为手 动 GetDlgItem(IDC_BTN_EXIT)EnableWindow(false)。 // ListView 初始化 DWORD dwStyle=GetWindowLong((),GWL_STYLE)。 dwStyleamp。 =~LVS_TYPEMASK。 dwStyle|=LVS_REPORT。 SetWindowLong((),GWL_STYLE,dwStyle)。 (0,MAC 地址 ,LVCFMT_LEFT,120)。 (0,用户 \\其它 ,LVCFMT_LEFT,100)。 (0,主机名 ,LVCFMT_LEFT,80)。 (0,工作组 ,LVCFMT_LEFT,80)。 (0,IP 地址 ,LVCFMT_LEFT,100)。 (LVS_EX_GRIDLINES)。 ::SendMessage(, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT)。 // return TRUE。 // return TRUE unless you set the focus to a control } void CchenzhenjunDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this)。 SendMessage(WM_ICONERASEBKGND, (WPARAM) (), 0)。 int cxIcon = GetSystemMetrics(SM_CXICON)。 int cyIcon = GetSystemMetrics(SM_CYICON)。 CRect rect。 GetClientRect(amp。 rect)。 int x = (() cxIcon + 1) / 2。 int y = (() cyIcon + 1) / 2。 (x, y, m_hIcon)。 } else { CDialog::OnPaint()。 } } HCURSOR CchenzhenjunDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon。 } UINT chenzhenjunThread(LPVOID param) { //循环对要查询的 ip 发数据 do { if(bExit) //是否退出线程 { AfxMessageBox(已停止扫描。 )。 pDlgGetDlgItem(IDC_BTN_SEND)EnableWindow(true)。 pDlgGetDlgItem(IDC_IPADDRESS1)EnableWindow(true)。 pDlgGetDlgItem(IDC_IPADDRESS2)EnableWindow(true)。 bExit=false。 return 1。 } pDlg(%d.%d.%d.%d,B1[0],B1[1],B1[2],B1[3])。 //得到 ip int len。 if(B1[3]!=0amp。 amp。 B1[1]!=0) len = pDlg((void*)bs,50,destPORT,pDlgm_strIP,0)。 //向指定的 ip 发数据报 // int nWait=pDlg()。 //设置超时 int nWait = 20。 if (len == 50) { WaitForSingleObject( wait_handle, // 等待事件的句柄 nWait // 超时 )。 ResetEvent(wait_handle)。 //将事件重新置回非触发状态 } //============================================= //生成下一个要查询的 ip if(B1[2]=B2[2]) { if(B1[3]B2[3])B1[3]++。 else if(B1[2]B2[2]amp。 amp。 B1[3]255)B1[3]++。 else if(B1[2]B2[2]amp。 amp。 B1[3]==255) { B1[3]=0。 B1[2]++。 } } else break。 if(B1[3]=B2[3]amp。 amp。 B1[2]=B2[2]) break。 }while(B1[2]=255amp。 amp。 B1[3]=255)。 pDlgGetDlgItem(IDC_BTN_SEND)EnableWindow(true)。 pDlgGetDlgItem(IDC_IPADDRESS1)EnableWindow(true)。 pDlgGetDlgItem(IDC_IPADDRESS2)EnableWindow(true)。 return 0。 } // void CchenzhenjunDlg::OnBtnSend() { //从 ip 控件得到要查询的 ip 范围 (B1[0],B1[1],B1[2],B1[3])。 (B2[0],B2[1],B2[2],B2[3])。 //判断 ip 范围是否合法 if(B2[2]B1[2]) { AfxMessageBox(终止地址应大于起始地址。 )。 return。 } else if(B2[2]==B1[2]amp。 amp。 B2[3]B1[3]) { AfxMessageBox(终止地址应大于起始地址。 )。 return。 } if(B2[0]!=B1[0]||B2[1]!=B1[1]) { AfxMessageBox(不支持 A 类或 B 类网。 )。 return。 } //设置相关按钮状态 GetDlgItem(IDC_BTN_SEND)EnableWindow(false)。 GetDlgItem(IDC_IPADDRESS1)EnableWindow(false)。 GetDlgItem(IDC_IPADDRESS2)EnableWindow(false)。 //启动线程 ( )。 AfxBeginThread(chenzhenjunThread,thisGetSafeHwnd(),THREAD_PRIORITY_NORMAL)。 } void CchenzhenjunDlg::OnReceive() { BYTE Buf[512]。 memset(Buf, 0, sizeof(Buf))。 CString str,strIP,strHost,strHex,strMac,Host,Group,User。 UINT dport。 (Buf,512,strIP。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。