⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipscan.cpp

📁 IPScan 这是一段简单的IP扫描代码
💻 CPP
字号:
// IPScan.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "IPScan.h"
#include "CardDlg.h"
#include "packet32.h"
#include "IPScanDlg.h"
#include "DataStruct.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CIPScanApp
extern	WCHAR		AdapterList[][256];
extern	PARASEND	pmSend;
BEGIN_MESSAGE_MAP(CIPScanApp, CWinApp)
	//{{AFX_MSG_MAP(CIPScanApp)
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CIPScanApp construction

CIPScanApp::CIPScanApp()
{
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CIPScanApp object

CIPScanApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CIPScanApp initialization

BOOL CIPScanApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	pmSend.pStatus = NULL;
	if (!NetInit())
		return FALSE;
	
	CIPScanDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
	}
	else if (nResponse == IDCANCEL)
	{
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

BOOL CIPScanApp::NetInit()
{
	// 取得所有已安装网卡的名称
	WCHAR		AdapterName[1024];
	WCHAR		*temp, *temp1;
	ULONG		AdapterLength = sizeof(AdapterName) / 2;
	int			i = 0;
	if (PacketGetAdapterNames((TCHAR *)AdapterName, &AdapterLength) == FALSE)
	{
		AfxMessageBox(_T("Unable to retrieve the list of the adapters!"), MB_ICONSTOP);
		return FALSE;
	}
	temp=AdapterName;
	temp1=AdapterName;
	while ((*temp!='\0')||(*(temp-1)!='\0'))
	{
		if (*temp=='\0') 
		{
			memcpy(AdapterList[i],temp1,(temp-temp1)*2);
			temp1=temp+1;
			i++;
		}
		temp++;
	}
	
	// 显示对话框,让用户选择所有安装的网卡
	CCardDlg dlg(i);
	if (dlg.DoModal() != IDOK)
	{
		return FALSE;
	}
	else
	{
		iOpen = dlg.nCurSel;
		return TRUE;
	}
}

int CIPScanApp::ExitInstance() 
{
	if (pmSend.pStatus)
	{
		delete[] pmSend.pStatus;
		pmSend.pStatus = NULL;
	}
	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -