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
/*
	CRegistry.h
	Classe base per l'accesso al registro (SDK/MFC).
	Luca Piergentili, 07/08/00
	lpiergentili@yahoo.com
	http://www.geocities.com/lpiergentili/
*/
#ifndef _CREGISTRY_H
#define _CREGISTRY_H 1

#include "window.h"

// id per le icone predefinite (windows.h)
enum IDI_PREDEFINED_ICON {
	IDI_APPLICATION_ICON,
	IDI_ASTERISK_ICON,
	IDI_EXCLAMATION_ICON,
	IDI_HAND_ICON,
	IDI_QUESTION_ICON,
	IDI_WINLOGO_ICON
};

// struttura per la registrazione del tipo file
struct REGISTERFILETYPE {
	char	extension[_MAX_EXT+1];		// estensione (.gzw)
	char	name[_MAX_PATH+1];			// nome del tipo (gzwfile)
	char	description[_MAX_PATH+1];	// descrizione (GZW compressed data)
	char	shell[_MAX_PATH+1];			// comando associato (c:\bin\gzwshell.exe)
	char	shellopenargs[_MAX_PATH+1];	// argomenti (%1)
	int	defaulticon;				// indice (base 0) per l'icona di default (0)
	char	contenttype[_MAX_PATH+1];	// tipo mime (application/x-gzw-compressed)
};
typedef REGISTERFILETYPE* LPREGISTERFILETYPE;

class CRegistry
{
public:
#if defined(_AFX) || defined(_AFX_DLL)
	CRegistry(HINSTANCE hInstance = AfxGetInstanceHandle())
#else
	CRegistry(HINSTANCE hInstance)
#endif
	{
		m_hInstance = hInstance;
	}
	virtual ~CRegistry() {}

	// registrazione tipo
	BOOL			RegisterFileType				(LPREGISTERFILETYPE lpRegFileType);
	BOOL			UnregisterFileType				(LPCSTR lpcszExtension);
	
	// icone per il tipo registrato
	BOOL			SetIconForRegisteredFileType		(LPREGISTERFILETYPE lpRegFileType);
	HICON		GetIconForRegisteredFileType		(LPCSTR lpcszExtension,LPREGISTERFILETYPE pFileType = NULL);
	HICON		GetSafeIconForRegisteredFileType	(LPCSTR lpcszExtension,LPREGISTERFILETYPE pFileType = NULL);
	HICON		GetSystemIcon					(IDI_PREDEFINED_ICON id);
	
	// programma per il tipo registrato (solo eseguibile, senza parametri ne opzioni)
	BOOL			GetProgramForRegisteredFileType	(LPCSTR lpcszFileName,LPSTR lpszProgram,int nSize);
	BOOL			ExecuteFileType				(LPCSTR lpcszFileName);

	// programma per il tipo registrato e operazioni basiche
	BOOL			GetCommandForRegisteredFileType	(LPCSTR lpcszCommand,LPCSTR lpcszFileName,LPSTR lpszProgram,int nSize);
	BOOL			ShellFileType					(LPCSTR lpcszCommand,LPCSTR lpcszFileName);
	inline BOOL	OpenFileType					(LPCSTR lpcszFileName) {return(ShellFileType("open",lpcszFileName));}
	inline BOOL	PrintFileType					(LPCSTR lpcszFileName) {return(ShellFileType("print",lpcszFileName));}

	// estensione relativa al tipo MIME
	LPSTR		GetContentTypeExtension			(LPCSTR lpcszContentType,LPSTR lpszExt,UINT nExtSize);

	// menu contestuale della shell
	BOOL			AddMenuEntryForRegisteredFileType	(LPCSTR lpcszExtension,LPCSTR lpcszMenuText,LPCSTR lpcszCommand);
	BOOL			RemoveMenuEntryForRegisteredFileType(LPCSTR lpcszExtension,LPCSTR lpcszMenuText);

private:
	HINSTANCE		m_hInstance;
};

#endif // _CREGISTRY_H

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

Share

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
Web01 | 2.8.140821.2 | Last Updated 28 Oct 2001
Article Copyright 2001 by Luca Piergentili
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid