Click here to Skip to main content
12,886,833 members (35,206 online)
Click here to Skip to main content

Stats

2.2M views
21.7K downloads
634 bookmarked
Posted 29 May 2002

Professional User Interface Suite

, 13 Jan 2004
MFC extension library enabling software to be provided with a professional UI
Prof-UIS
Bin_600
Bin_700
Bin_710
Include
profuisdll
idd_ext_color_dlg.ico
profuisdll.def
profuisdll_600.dsp
profuisdll_600.dsw
res
black_arrow_bottom.cur
black_arrow_left.cur
black_arrow_right.cur
black_arrow_top.cur
cmd00001.cur
cmd00002.cur
cmd00003.cur
cur_arrow_invert.cur
cur_black_finger.cur
cur_black_hand.cur
cur_hand_like.cur
cur_pan_all.cur
cur_pan_bottom.cur
cur_pan_bottom_left.cur
cur_pan_bottom_right.cur
cur_pan_horz.cur
cur_pan_left.cur
cur_pan_right.cur
cur_pan_top.cur
cur_pan_top_left.cur
cur_pan_top_right.cur
cur_pan_vert.cur
cur_resize_h1.cur
cur_resize_h2.cur
cur_resize_v1.cur
cur_resize_v2.cur
cur00001.cur
cur00002.cur
cur00003.cur
cur00004.cur
hollow_cross_normal.cur
hollow_cross_small.cur
ico00001.ico
id_view_.bmp
idd_ext_.ico
idd_icon.ico
ied_cp.cur
ied_el.cur
ied_fill.cur
ied_line.cur
ied_pen.cur
ied_rect.cur
ied_tool.cur
suppress.cur
suppress_arrow.cur
toolbar_.bmp
zoom_hollow.cur
zoom_minus.cur
zoom_plus.cur
profuislib
profuislib_600.dsp
profuislib_600.dsw
Samples
AviFrames
AviFrames_600.dsp
res
AviFrames.ico
CINEAPK.AVI
IDR_TOOLBAR_PLAYER.bmp
IDR_TOOLBAR_UISTYLE.bmp
Toolbar.bmp
toolbar2.bmp
xptheme.bin
DRAWCLI
DRAWCLI_600.dsp
L.JPN
RES
res
DRAWCLI.ICO
DRAWDOC.ICO
ico00001.ico
ico00002.ico
ico00003.ico
ico00004.ico
ico00005.ico
ico00006.ico
ico00007.ico
ico00008.ico
icon1.ico
id_objec.ico
id_scppv.ico
idr_abou.ico
PENCIL.CUR
TOOLBAR_1_16bit.bmp
TOOLBAR_1_4bit.bmp
TOOLBAR_2_16bit.bmp
TOOLBAR_2_4bit.bmp
FixedSizePanels
FixedSizePanels_600.dsp
res
bitmap_t.bmp
FixedSizePanels.ico
Toolbar.bmp
toolbar2.bmp
FullScreenState
FullScreenState_600.dsp
res
FullScreenState.ico
idr_mdit.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
toolbar4.bmp
FunnyBars
FunnyBars_600.dsp
res
FunnyBars.ico
Toolbar.bmp
toolbar_16_16_8.bmp
toolbar_44_40_32.bmp
winXP.manifest
GLViews
GLViews_600.dsp
res
bitmap_i.bmp
bitmap_s.bmp
bitmap_t.bmp
bmp00001.bmp
btpnlane.bmp
CINEAPK.AVI
cur00001.cur
cur00002.cur
cursor_g.cur
earth.bmp
GLViews.ico
moon.bmp
ProfUisCubeSideOrange.bmp
ProfUisCubeSideWhite.bmp
ring.bmp
Toolbar.bmp
toolbar_.bmp
toolbar2.bmp
wndavipl.bmp
wndmirror.bmp
res_html
bodytop.gif
book_close.gif
book_open.gif
MDI
MDI_600.dsp
res
idr_mdit.ico
MDI.ico
Toolbar.bmp
toolbar2.bmp
MDI_InnerOuterBars
MDI_InnerOuterBars_600.dsp
res
bmp00001.bmp
idr_mdit.ico
MDI_InnerOuterBars.ico
Toolbar.bmp
toolbar_.bmp
toolbar2.bmp
MDIDOCVIEW
MDIDOCVIEW_600.dsp
res
MDIDOCVIEW.ico
MDIDOCVIEWDoc.ico
Toolbar.bmp
MthOutput
MthOutput_600.dsp
res
idr_mdit.ico
MthOutput.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
ProfUIS_Controls
ProfUIS_Controls_600.dsp
res
bitmap1.bmp
bitmap2.bmp
icon1.ico
ProfUIS_Controls.ico
tab_imag.bmp
toolbar1.bmp
ResizableChildSheet
res
idr_chil.ico
ResizableChildSheet.ico
Toolbar.bmp
ResizableChildSheet_600.dsp
ResizablePropertySheet
res
bitmap1.bmp
bitmap2.bmp
ResizablePropertySheet.ico
ResizablePropertySheet_600.dsp
SDI
res
SDI.ico
Toolbar.bmp
toolbar2.bmp
SDI_600.dsp
SDIDOCVIEW
res
SDIDOCVIEW.ico
SDIDOCVIEWDoc.ico
Toolbar.bmp
SDIDOCVIEW_600.dsp
StateInFile
res
StateInFile.ico
Toolbar.bmp
StateInFile_600.dsp
StatusPanes
res
download.avi
StatusPanes.ico
Toolbar.bmp
toolbar2.bmp
StatusPanes_600.dsp
Src
Workspace
ProfUIS_600.dsw
Include
profuisdll
idd_ext_color_dlg.ico
profuisdll.def
profuisdll.dsp
res
profuislib
profuislib.dsp
Samples
DRAWCLI
MDI
MDIDOCVIEW
MDI_InnerOuterBars
ProfUIS_Controls
ResizablePropertySheet
SDI
SDIDOCVIEW
StateInFile
DRAWCLI.dsp
L.JPN
res
RES
DRAWCLI.ICO
DRAWDOC.ICO
ico00001.ico
ico00002.ico
icon1.ico
id_objec.ico
PENCIL.CUR
TOOLBAR.BMP
MDI.dsp
res
idr_mdit.ico
MDI.ico
Toolbar.bmp
toolbar2.bmp
MDIDOCVIEW.dsp
res
MDIDOCVIEW.ico
MDIDOCVIEWDoc.ico
Toolbar.bmp
MDI_InnerOuterBars.dsp
res
bmp00001.bmp
idr_mdit.ico
MDI_InnerOuterBars.ico
Toolbar.bmp
toolbar2.bmp
toolbar_.bmp
ProfUIS_Controls.dsp
res
bitmap1.bmp
bitmap2.bmp
icon1.ico
ProfUIS_Controls.ico
tab_imag.bmp
toolbar1.bmp
res
ResizablePropertySheet.dsp
ResizablePropertySheet.ico
res
SDI.dsp
SDI.ico
Toolbar.bmp
toolbar2.bmp
res
SDIDOCVIEW.dsp
SDIDOCVIEW.ico
SDIDOCVIEWDoc.ico
Toolbar.bmp
res
StateInFile.dsp
StateInFile.ico
Toolbar.bmp
Src
Workspace
ProfUIS.dsw
ProfUIS.suo
Bin
MDI.exe
ProfUIS21.dll
ProfUIS_Controls.exe
SDI.exe
StateInFile.exe
idd_ext_color_dlg.ico
profuisdll.aps
profuisdll.clw
profuisdll.def
profuisdll.dep
profuisdll.dsp
profuisdll.mak
profuisdll.plg
MDI.APS
MDI.clw
MDI.dep
MDI.dsp
MDI.mak
MDI.plg
idr_mdit.ico
MDI.ico
Toolbar.bmp
toolbar2.bmp
ProfUIS_Controls.aps
ProfUIS_Controls.clw
ProfUIS_Controls.dep
ProfUIS_Controls.dsp
ProfUIS_Controls.mak
ProfUIS_Controls.ico
toolbar1.bmp
SDI.APS
SDI.clw
SDI.dep
SDI.dsp
SDI.mak
SDI.plg
SDI.ico
Toolbar.bmp
toolbar2.bmp
StateInFile.aps
StateInFile.clw
StateInFile.dep
StateInFile.dsp
StateInFile.mak
StateInFile.plg
StateInFile.ico
Toolbar.bmp
ProfUIS.dsw
ProfUIS.ncb
ProfUIS.opt
// This is part of the Professional User Interface Suite library.
// Copyright (C) 2001-2004 FOSS Software, Inc.
// All rights reserved.
//
// http://www.prof-uis.com
// http://www.fossware.com
// mailto:foss@fossware.com
//
// This source code can be used, modified and redistributed
// under the terms of the license agreement that is included
// in the Professional User Interface Suite package.
//
// Warranties and Disclaimers:
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
// INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
// IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
// INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
// INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

#if (!defined __EXT_REGISTRY_H)
#define __EXT_REGISTRY_H

#if (!defined __EXT_MFC_DEF_H)
	#include <ExtMfcDef.h>
#endif // __EXT_MFC_DEF_H

class __PROF_UIS_API CExtRegistry
{
public:
    HKEY hKey;

	CExtRegistry()
	{
		Open();
	};
	~CExtRegistry()
	{
		Close();
	};

	static HKEY RegOpen(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		DWORD dwRights
		)
	{
		HKEY hSubKey;
		if( RegOpenKeyEx(
				hKey,
				pszSubKey,
				0,
				dwRights,
				&hSubKey
				) == ERROR_SUCCESS
			)
		{
			return hSubKey;
		}
		return NULL;
	};
	static void RegClose(HKEY hKey)
	{
		if( hKey )
			RegCloseKey( hKey );
	};
	static HKEY RegConnect(
		HKEY hKey, 
		__EXT_MFC_SAFE_LPCTSTR pszRemote
		)
	{
		HKEY hSubKey;
		if( RegConnectRegistry(
				pszRemote,
				hKey,
				&hSubKey
				) == ERROR_SUCCESS
				)
		{
			return hSubKey;
		}
		return NULL;
	}
	static HKEY RegCreate(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		DWORD dwRights
		)
	{
		HKEY hSubKey;
		DWORD dwDisposition;
		if( RegCreateKeyEx(
				hKey,
				pszSubKey,
				0,
				NULL,
				REG_OPTION_NON_VOLATILE,
				dwRights,
				NULL,
				&hSubKey,
				&dwDisposition
				) == ERROR_SUCCESS
			)
		{
			return hSubKey;
		}
		return NULL;
	}

	HKEY Connect(
		HKEY hNewKey,
		__EXT_MFC_SAFE_LPCTSTR pszRemote
		)
	{
		return
			hKey = RegConnect(hNewKey, pszRemote);
	};
	HKEY Create(
		HKEY hNewKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		DWORD dwRights
		)
	{
		return
			hKey = RegCreate(hNewKey, pszSubKey, dwRights);
	};
	HKEY Open(
		HKEY hNewKey = NULL
		)
	{
		return hKey = hNewKey;
	};
	HKEY Open(
		HKEY hNewKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		DWORD dwRights
		)
	{
		return hKey =
			RegOpen(hNewKey, pszSubKey, dwRights);
	};
	void Close()
	{
		if( hKey != NULL )
		{
			RegClose(hKey);
			hKey = NULL;
		}
	};

	static bool RegLoadString(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		__EXT_MFC_SAFE_LPCTSTR pszString, DWORD dwLength
		)
	{
		ASSERT( pszString != NULL );
		dwLength *= sizeof(TCHAR);
		HKEY hSubKey = pszSubKey ? RegOpen (hKey, pszSubKey, KEY_READ) : hKey;
		if( hSubKey )
		{
			DWORD dwType, dwRealLength;
			if( RegQueryValueEx(
					hSubKey, pszValName, 0, &dwType,
					NULL, &dwRealLength
					) == ERROR_SUCCESS
				)
			{
				if(	(dwType == REG_SZ
					|| dwType == REG_EXPAND_SZ
					|| dwType == REG_LINK
					|| dwType == REG_MULTI_SZ
					)
					&&
					dwLength >= dwRealLength
					)
				{
					if( RegQueryValueEx(
							hSubKey, pszValName, 0, NULL,
							(LPBYTE) (LPCTSTR) pszString, &dwRealLength
							) == ERROR_SUCCESS
						)
					{
						if( hSubKey != hKey )
							RegClose( hSubKey );
						return true;
					}
				}
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};
	static bool RegLoadNewString(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName,
		__EXT_MFC_SAFE_LPCTSTR *pszString, DWORD *pdwLength
		)
	{
		ASSERT(pszString);
		HKEY hSubKey =
			pszSubKey ?
				RegOpen(hKey, pszSubKey, KEY_READ) : hKey;
		if( hSubKey )
		{
			DWORD dwType, dwRealLength;
			if (RegQueryValueEx (hSubKey, pszValName, 0, &dwType, NULL, &dwRealLength) == ERROR_SUCCESS)
			{
				if( dwType == REG_SZ
					|| dwType == REG_EXPAND_SZ
					|| dwType == REG_LINK
					|| dwType == REG_MULTI_SZ
					)
				{
					__EXT_MFC_SAFE_LPCTSTR pszNewString = (LPCTSTR)
						::malloc( dwRealLength*sizeof(TCHAR) );
					if( pszNewString )
					{
						if( RegQueryValueEx(
								hSubKey, pszValName,
								0, NULL,
								(LPBYTE) (LPCTSTR) pszNewString,
								&dwRealLength
								) == ERROR_SUCCESS
							)
						{
							*pszString = pszNewString;
							if( pdwLength )
							{
								*pdwLength = dwRealLength;
							}
							if( hSubKey != hKey )
								RegClose( hSubKey );
							dwRealLength /= sizeof(TCHAR);
							return true;
						}
						::free( (LPVOID) (LPCTSTR) pszNewString );
					}
				}
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};
	static bool RegSaveString(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName,
		__EXT_MFC_SAFE_LPCTSTR pszString
		)
	{
		HKEY hSubKey =
			pszSubKey ?
			RegCreate(hKey, pszSubKey, KEY_WRITE) : hKey;
		if( hSubKey )
		{
			if( RegSetValueEx(
					hSubKey,
					pszValName, 0, REG_SZ,
					(LPBYTE) (LPCTSTR) pszString,
					(_tcslen(pszString) + 1)*sizeof(TCHAR)
					) == ERROR_SUCCESS
				)
			{
				if( hSubKey != hKey )
					RegClose( hSubKey );
				return true;
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};

	bool LoadNewString(__EXT_MFC_SAFE_LPCTSTR pszValName, __EXT_MFC_SAFE_LPCTSTR *pszString, DWORD *pdwLength)
	{
		return RegLoadNewString(hKey, NULL, pszValName, pszString, pdwLength);
	};
	bool LoadNewString(__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName, __EXT_MFC_SAFE_LPCTSTR *pszString, DWORD *pdwLength)
	{
		return RegLoadNewString(hKey, pszSubKey, pszValName, pszString, pdwLength);
	};
	bool LoadString(__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName, __EXT_MFC_SAFE_LPCTSTR pszString, DWORD dwLength)
	{
		return RegLoadString(hKey, pszSubKey, pszValName, pszString, dwLength);
	};
	bool LoadString(__EXT_MFC_SAFE_LPCTSTR pszValName, __EXT_MFC_SAFE_LPCTSTR pszString, DWORD dwLength)
	{
		return RegLoadString(hKey, NULL, pszValName, pszString, dwLength);
	};
	bool SaveString(__EXT_MFC_SAFE_LPCTSTR pszValName, __EXT_MFC_SAFE_LPCTSTR pszString)
	{
		return RegSaveString(hKey, NULL, pszValName, pszString);
	};
	bool SaveString(__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName, __EXT_MFC_SAFE_LPCTSTR pszString)
	{
		return RegSaveString(hKey, pszSubKey, pszValName, pszString);
	};

	static bool RegLoadNumber(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		DWORD *pdwNumber
		)
	{
		ASSERT(pdwNumber);
		HKEY hSubKey =
			pszSubKey ?
				RegOpen(hKey, pszSubKey, KEY_READ) : hKey;
		if (hSubKey)
		{
			DWORD dwType, dwSize;
			if( RegQueryValueEx(
					hSubKey, pszValName, 0, &dwType,
					NULL, &dwSize
					) == ERROR_SUCCESS
				)
			{
				if( dwType == REG_DWORD )
				{
					ASSERT(dwSize == sizeof (DWORD));
					if( RegQueryValueEx(
							hSubKey, pszValName, 0, NULL,
							(LPBYTE) pdwNumber, &dwSize
							) == ERROR_SUCCESS
						)
					{
						ASSERT(dwSize == sizeof (DWORD));
						if( hSubKey != hKey )
							RegClose( hSubKey );
						return true;
					}
				}
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};
	static bool RegSaveNumber(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		DWORD dwNumber
		)
	{
		HKEY hSubKey =
			pszSubKey ?
				RegCreate(hKey, pszSubKey, KEY_WRITE) : hKey;
		if( hSubKey )
		{
			if( RegSetValueEx(
					hSubKey, pszValName, 0, REG_DWORD,
					(LPBYTE) &dwNumber, sizeof (DWORD)
					) == ERROR_SUCCESS
				)
			{
				if( hSubKey != hKey )
					RegClose( hSubKey );
				return true;
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};

	bool LoadNumber(__EXT_MFC_SAFE_LPCTSTR pszValName, DWORD *pdwNumber)
	{
		return RegLoadNumber(hKey, NULL, pszValName, pdwNumber);
	};
	bool LoadNumber(__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName, DWORD *pdwNumber)
	{
		return RegLoadNumber(hKey, pszSubKey, pszValName, pdwNumber);
	};
	bool SaveNumber(__EXT_MFC_SAFE_LPCTSTR pszValName, DWORD dwNumber)
	{
		return RegSaveNumber(hKey, NULL, pszValName, dwNumber);
	};
	bool SaveNumber(__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName, DWORD dwNumber)
	{
		return RegSaveNumber(hKey, pszSubKey, pszValName, dwNumber);
	};

	static bool RegLoadBinary(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		LPBYTE pbyteData,
		DWORD dwSize
		)
	{
		ASSERT(pbyteData);
		HKEY hSubKey =
			pszSubKey ?
				RegOpen(hKey, pszSubKey, KEY_READ) : hKey;
		if( hSubKey )
		{
			DWORD dwType, dwRealSize;
			if( RegQueryValueEx(
					hSubKey, pszValName, 0, &dwType, NULL,
					&dwRealSize
					) == ERROR_SUCCESS
				)
			{
				if( dwType == REG_BINARY
					&& dwSize >= dwRealSize
					)
				{
					if( RegQueryValueEx(
							hSubKey, pszValName, 0, NULL,
							pbyteData, &dwRealSize
							) == ERROR_SUCCESS
						)
					{
						if( hSubKey != hKey )
							RegClose( hSubKey );
						return true;
					}
				}
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};
	static bool RegLoadNewBinary(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName,
		LPBYTE *pbyteData,
		DWORD *pdwSize
		)
	{
		ASSERT(pbyteData);
		HKEY hSubKey =
			pszSubKey ?
				RegOpen(hKey, pszSubKey, KEY_READ) : hKey;
		if( hSubKey )
		{
			DWORD dwType, dwRealSize;
			if( RegQueryValueEx(
					hSubKey, pszValName,
					0, &dwType, NULL,
					&dwRealSize
					) == ERROR_SUCCESS
				)
			{
				if( dwType == REG_BINARY )
				{
					LPBYTE pbyteNewData = (LPBYTE)
						::malloc( dwRealSize*sizeof(TCHAR) );
					if( pbyteNewData )
					{
						if( RegQueryValueEx(
								hSubKey, pszValName, 0, NULL,
								pbyteNewData, &dwRealSize
								) == ERROR_SUCCESS
							)
						{
							*pbyteData = pbyteNewData;
							*pdwSize = dwRealSize;
							if( hSubKey != hKey )
								RegClose( hSubKey );
							return true;
						}
						::free( pbyteNewData );
					}
				}
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};
	static bool RegSaveBinary(
		HKEY hKey,
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		const LPBYTE pbyteData,
		DWORD dwSize
		)
	{
		HKEY hSubKey =
			pszSubKey ?
				RegCreate(hKey, pszSubKey, KEY_WRITE) : hKey;
		if( hSubKey )
		{
			if( RegSetValueEx(
					hSubKey, pszValName, 0, REG_BINARY,
					pbyteData, dwSize
					) == ERROR_SUCCESS
				)
			{
				if( hSubKey != hKey )
					RegClose( hSubKey );
				return true;
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};

	bool LoadBinary(
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		LPBYTE pbyteData,
		DWORD dwSize
		)
	{
		return
			RegLoadBinary(
				hKey,
				NULL,
				pszValName,
				pbyteData,
				dwSize
				);
	};
	bool LoadBinary(
		__EXT_MFC_SAFE_LPCTSTR pszSubKey,
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		LPBYTE pbyteData,
		DWORD dwSize
		)
	{
		return
			RegLoadBinary(
				hKey,
				pszSubKey,
				pszValName,
				pbyteData,
				dwSize
				);
	};
	bool LoadNewBinary(
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		LPBYTE *pbyteData,
		DWORD *pdwSize
		)
	{
		return
			RegLoadNewBinary(
				hKey,
				NULL,
				pszValName,
				pbyteData,
				pdwSize
				);
	};
	bool LoadNewBinary(
			__EXT_MFC_SAFE_LPCTSTR pszSubKey,
			__EXT_MFC_SAFE_LPCTSTR pszValName,
			LPBYTE *pbyteData,
			DWORD *pdwSize
			)
	{
		return
			RegLoadNewBinary(
				hKey,
				pszSubKey,
				pszValName,
				pbyteData,
				pdwSize
				);
	};
	bool SaveBinary(
		__EXT_MFC_SAFE_LPCTSTR pszValName,
		const LPBYTE pbyteData,
		DWORD dwSize
		)
	{
		return
			RegSaveBinary(
				hKey, NULL, pszValName,
				pbyteData, dwSize
				);
	};
	bool SaveBinary(
		__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName,
		const LPBYTE pbyteData, DWORD dwSize
		)
	{
		return
			RegSaveBinary(
				hKey, pszSubKey, pszValName,
				pbyteData, dwSize
				);
	};

	static bool RegDeleteKey(
		HKEY hKey, __EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName
		)
	{
		HKEY hSubKey =
			pszSubKey ?
				RegOpen(hKey, pszSubKey, KEY_READ | KEY_WRITE)
				: 
				hKey;
		if( hSubKey )
		{
			if( pszValName )
			{
				if( RegDeleteValue(
						hSubKey,
						pszValName
						) == ERROR_SUCCESS
					)
				{
					if( hSubKey != hKey )
						RegClose( hSubKey );
					return true;
				}
			}
			else
			{
				if( RegDeleteSubKeys(hSubKey) )
				{
					if( hSubKey != hKey )
						RegClose (hSubKey);
					return
						::RegDeleteKey(
							hKey,
							pszSubKey
							) == ERROR_SUCCESS;
				}
			}
			if( hSubKey != hKey )
				RegClose( hSubKey );
		}
		return false;
	};
	static bool RegDeleteSubKeys(HKEY hKey)
	{
		DWORD dwSubKeyCnt, dwMaxSubKey;
		if( RegQueryInfoKey(
				hKey,
				NULL,
				NULL,
				0,
				&dwSubKeyCnt,
				&dwMaxSubKey,
				NULL,
				NULL,
				NULL,
				NULL,
				NULL,
				NULL
				) == ERROR_SUCCESS
			)
		{
			if( dwSubKeyCnt )
			{
				dwMaxSubKey += 1;
				__EXT_MFC_SAFE_LPTSTR pszKeyName = (LPTSTR)
					::malloc( dwMaxSubKey*sizeof(TCHAR) );
				if( pszKeyName != NULL )
				{
					do
					{
						if( RegEnumKey(
								hKey,
								--dwSubKeyCnt,
								pszKeyName,
								dwMaxSubKey
								) == ERROR_SUCCESS
							)
						{
							HKEY hSubKey =
								RegOpen(
									hKey,
									(LPCTSTR) pszKeyName,
									KEY_READ | KEY_WRITE
									);
							if( hSubKey )
							{
								if( RegDeleteSubKeys(hSubKey) )
								{
									RegClose( hSubKey );
									if( ::RegDeleteKey(
											hKey,
											pszKeyName
											) != ERROR_SUCCESS
										)
									{
										::free( (LPVOID) (LPCTSTR) pszKeyName );
										return false;
									}
								}
								else
								{
									RegClose( hSubKey );
									::free( (LPVOID) (LPCTSTR) pszKeyName );
									return false;
								}
							}
							else
							{
								::free( (LPVOID) (LPCTSTR) pszKeyName );
								return false;
							}
						}
						else
						{
							::free( (LPVOID) (LPCTSTR) pszKeyName );
							return false;
						}
					}
					while( dwSubKeyCnt );
					::free( (LPVOID) (LPCTSTR) pszKeyName );
				}
				else
				{
					return false;
				}
			}
			return true;
		}
		return false;
	};

	bool DeleteKey(__EXT_MFC_SAFE_LPCTSTR pszValName)
	{
		return RegDeleteKey(hKey, NULL, pszValName);
	};
	bool DeleteKey(
		__EXT_MFC_SAFE_LPCTSTR pszSubKey, __EXT_MFC_SAFE_LPCTSTR pszValName)
	{
		return RegDeleteKey(hKey, pszSubKey, pszValName);
	};
	bool DeleteSubKeys()
	{
		return RegDeleteSubKeys( hKey );
	};
}; // class CExtRegistry

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

Sergiy Lavrynenko of Foss Software, Inc.
Architect Foss Software Inc
Ukraine Ukraine
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 14 Jan 2004
Article Copyright 2002 by Sergiy Lavrynenko of Foss Software, Inc.
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid