Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

How to write a simple but effective TCP/IP port scanner for Win32

, 27 Oct 2001
An article on how to write a TCP/IP port scanner with a GUI, based on the MFC's property sheet paradigm
/*
	TcpPropertySheet.cpp
	Luca Piergentili, 14/07/99
	lpiergentili@yahoo.com
	http://www.geocities.com/lpiergentili/
*/
#include "env.h"
#include "pragma.h"
#include <ctype.h>
#include <string.h>
#include "strcpyn.h"
#include "window.h"
#include "CPropertySheetDialog.h"
#include "CPropertyPageDialog.h"
#include "TcpScanConfig.h"
#include "TcpScanVersion.h"
#include "TcpPropertySheet.h"
#include "TcpScanPage.h"
#include "TcpConnectPage.h"
#include "TcpServicesPage.h"
#include "resource.h"

IMPLEMENT_DYNCREATE(CTcpScanPropertySheet,CPropertySheetDialog)

BEGIN_MESSAGE_MAP(CTcpScanPropertySheet,CPropertySheetDialog)
END_MESSAGE_MAP()

/*
	CTcpScanPropertySheet()
*/
CTcpScanPropertySheet::CTcpScanPropertySheet(CWnd* pParentWnd,CPropertyPageList* pagearray) : CPropertySheetDialog(pParentWnd,pagearray)
{
	// carica la configurazione dal registro
	if((m_pConfig = new CTcpScanConfig())==NULL)
	{
		AfxMessageBox("Unable to load the configuration from the registry.",MB_ICONWARNING);
		return;
	}

	// passa il puntatore alla configurazione alle pagine dello sheet
	ITERATOR iter;
	PROPERTYPAGE* p;
	if((iter = pagearray->First())!=(ITERATOR)NULL)
		while(iter!=(ITERATOR)NULL)
		{
			p = (PROPERTYPAGE*)iter->data;
			
			if(p->idd > 0)
				if(p->page)
				{
					CPropertyPageDialog* page = (CPropertyPageDialog*)p->page;

					if(p->runtimeclass==RUNTIME_CLASS(CScanPage))
						((CScanPage*)page)->GetPropertySheetConfig(m_pConfig);
					if(p->runtimeclass==RUNTIME_CLASS(CConnectPage))
						((CConnectPage*)page)->GetPropertySheetConfig(m_pConfig);
					if(p->runtimeclass==RUNTIME_CLASS(CServicesPage))
						((CServicesPage*)page)->GetPropertySheetConfig(m_pConfig);
				}

			iter = pagearray->Next(iter);
		}
}

/*
	~CTcpScanPropertySheet()
	
	Distruttore.
*/
CTcpScanPropertySheet::~CTcpScanPropertySheet()
{
	if(m_pConfig)
		delete m_pConfig,m_pConfig = NULL;
}

/*
	OnInitDialog()

	Inizializza il property sheet.
	Rimappa la funzione base per modificare lo stile del dialogo.
*/
BOOL CTcpScanPropertySheet::OnInitDialog(void)
{
	// notare che la CPropertySheet::OnInitDialog() chiama la OnInitDialog() e la OnSetActive()
	// della pagina di default (la prima ad essere aggiunta con AddPage())
	CPropertySheetDialog::OnInitDialog();

	// icone
	SetIcon(AfxGetApp()->LoadIcon(IDI_TCPSCAN),FALSE);
	SetIcon(AfxGetApp()->LoadIcon(IDI_TCPSCAN),TRUE);

	// titolo
	CPropertySheetDialog::SetTitle(PROGRAM_NAME);

	return(TRUE);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Luca Piergentili
Web Developer
Italy Italy
I like C and C++, Acid Jazz, James Brown, gli Spaghetti Aglio e Olio, alla Bolognesa, alla Puttanesca e le Fettuccine alla Matriciana ('Maccaroni' over the world). Of course I like beautiful big tits girls too, my little car, Frank Zappa, the art of Zen, italian coffee and much more...

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 28 Oct 2001
Article Copyright 2001 by Luca Piergentili
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid