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
/*
	CRegKey.h
	Classe base per l'accesso al registro (SDK).
	Riadattata dal codice originale ATL (M$) (vedi http://codeguru.earthweb.com/system/CRegKey.shtml).
	Luca Piergentili, 14/07/99
	lpiergentili@yahoo.com
	http://www.geocities.com/lpiergentili/
*/
#ifndef _CREGKEY_H
#define _CREGKEY_H

#include <stdio.h>
#include <stdlib.h>
#include "window.h"
#include <winreg.h>

#define REGKEY_MAX_SECTION_NAME	_MAX_PATH				// dim. max. nome sezione
#define REGKEY_MAX_KEY_NAME		REGKEY_MAX_SECTION_NAME	// dim. max. nome chiave
#define REGKEY_MAX_KEY_VALUE		REGKEY_MAX_SECTION_NAME	// dim. max. chiave

class CRegKey
{
public:
	CRegKey()									{m_hKey = NULL;}
	virtual ~CRegKey()							{CRegKey::Close();}

	inline void	Attach			(HKEY hKey)	{m_hKey = hKey;}
	HKEY			Detach			(void);

	LONG			Create			(HKEY hKeyParent,
								LPCSTR lpcszKeyName,
								LPSTR = REG_NONE,
								DWORD = REG_OPTION_NON_VOLATILE,
								REGSAM = KEY_ALL_ACCESS,
								LPSECURITY_ATTRIBUTES = NULL,
								LPDWORD = NULL
								);

	LONG			Open				(HKEY hKeyParent,LPCSTR lpcszKeyName,REGSAM = KEY_ALL_ACCESS);
	LONG			Close			(void);

	LONG			QueryValue		(LPSTR lpszValue,LPCSTR lpcszValueName,DWORD* pdwCount);
	LONG			QueryValue		(DWORD& dwValue,LPCSTR lpcszValueName);

	LONG			SetValue			(LPCSTR lpcszValue,LPCSTR lpcszValueName = NULL);
	LONG			SetValue			(DWORD dwValue,LPCSTR lpcszValueName);
	LONG			SetBinaryValue		(DWORD dwValue,LPCSTR lpcszValueName);
	LONG WINAPI	SetValue			(HKEY hKeyParent,LPCSTR lpcszKeyName,LPCSTR lpcszValue,LPCSTR lpcszValueName = NULL);
	LONG			SetKeyValue		(LPCSTR lpcszKeyName,LPCSTR lpcszValue,LPCSTR lpcszValueName = NULL);

	BOOL			DeleteValue		(LPCSTR lpcszValue);
	BOOL			DeleteKey			(LPCSTR lpcszKey);
	BOOL			DeleteSubKey		(LPCSTR lpcszSubKey);
	
	operator		HKEY() const		{return(m_hKey);}

private:
	HKEY m_hKey;
};

#endif // _CREGKEY_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

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.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