class LboxReg


  オブジェクトの作成と削除および使用例




  

LboxDlg *Dlg;
LboxReg *Reg;
LboxString Buff;

LRESULT CALLBACK About( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	switch( message ) {
		case WM_INITDIALOG:
			Dlg = new LboxDlg( hDlg );

			Reg = new LboxReg(
				HKEY_LOCAL_MACHINE,
				"SOFTWARE\\"
				"Microsoft\\"
				"VisualStudio\\"
				"6.0\\"
				"Setup\\"
				"Microsoft Visual C++"
			);

			Reg->GetStrValue( "ProductDir", &Buff );
			Dlg->EditSetText( IDC_EDIT1, &Buff );

			return TRUE;

		case WM_COMMAND:
			if( LOWORD(wParam) == IDCANCEL ) {
				Dlg->End( LOWORD(wParam) );
				delete Reg;
				delete Dlg;
			}
			break;
	}
	return FALSE;
}
  

  コンストラクタ




  

// *********************************************************
// 標準コンストラクタ
// *********************************************************
LboxReg::LboxReg()
{
	LboxReg::hKey = NULL;
}

// *********************************************************
// 拡張コンストラクタ
// *********************************************************
LboxReg::LboxReg(HKEY hRoot, LPCTSTR lpSubKey)
{
	LONG	nRet;

	nRet = RegOpenKeyEx(
		hRoot,
		lpSubKey,
		0,
		KEY_ALL_ACCESS,
		&(LboxReg::hKey)
	);
	if ( nRet != ERROR_SUCCESS ) {
		LboxReg::hKey = NULL;
	}

}

// *********************************************************
// デストラクタ
// *********************************************************
LboxReg::~LboxReg()
{
	if ( LboxReg::hKey != NULL ) {
		RegCloseKey( LboxReg::hKey );
	}
}
  

  GetStrValue

  

// *********************************************************
// 文字列値の取得
// *********************************************************
BOOL LboxReg::GetStrValue(LPCTSTR lpEntry, LboxString &LString)
{
	return(LboxReg::GetStrValue(lpEntry, &LString));
}
BOOL LboxReg::GetStrValue(LPCTSTR lpEntry, LboxString *LString)
{
	DWORD nType,nSize;
	LONG nRet;

	nSize = LString->nLboxString;

	nRet = RegQueryValueEx(
		LboxReg::hKey,
		lpEntry,
		NULL,
		&nType,
		(LPBYTE)(LString->szLboxString),
		&nSize
	);

	if ( nRet == ERROR_SUCCESS ) {
		return TRUE;
	}
	else {
		if ( nRet == ERROR_MORE_DATA ) {
			LString->Resize( nSize );
			nRet = RegQueryValueEx(
				LboxReg::hKey,
				lpEntry,
				NULL,
				&nType,
				(LPBYTE)(LString->szLboxString),
				&nSize
			);
			if ( nRet == ERROR_SUCCESS ) {
				return TRUE;
			}
			else {
				return FALSE;
			}
		}
		else {
			return FALSE;
		}
	}
}
  

  SetStrValue

  

// *********************************************************
// 文字列値の登録
// *********************************************************
BOOL LboxReg::SetStrValue(LPCTSTR lpEntry, LboxString &LString)
{
	return LboxReg::SetStrValue( lpEntry, LString.szLboxString );
}
BOOL LboxReg::SetStrValue(LPCTSTR lpEntry, LboxString *LString)
{
	return LboxReg::SetStrValue( lpEntry, LString->szLboxString );
}
BOOL LboxReg::SetStrValue(LPCTSTR lpEntry, LPTSTR lpValue)
{
	LONG nRet;

	nRet =  RegSetValueEx(
		LboxReg::hKey,
		lpEntry,
		0,
		REG_SZ,
		(const unsigned char *)lpValue,
		lstrlen(lpValue)+1
	);

	if ( nRet == ERROR_SUCCESS ) {
		return TRUE;
	}
	else {
		return FALSE;
	}
}
  

  GetDwordValue

  

// *********************************************************
// DWORD 値の取得
// *********************************************************
BOOL LboxReg::GetDwordValue(LPCTSTR lpEntry, DWORD &Value )
{
	return(LboxReg::GetDwordValue(lpEntry, &Value ));
}
BOOL LboxReg::GetDwordValue(LPCTSTR lpEntry, DWORD *Value )
{
	DWORD nType,nSize;
	LONG nRet;

	nSize = 4;

	nRet = RegQueryValueEx(
		LboxReg::hKey,
		lpEntry,
		NULL,
		&nType,
		(LPBYTE)Value,
		(unsigned long *)(&nSize)
	);

	if ( nRet == ERROR_SUCCESS ) {
		return TRUE;
	}
	else {
		return FALSE;
	}
}
  

  SetDwordValue

  

// *********************************************************
// DWORDの登録
// *********************************************************
BOOL LboxReg::SetDwordValue(LPCTSTR lpEntry, DWORD dwValue )
{
	LONG nRet;
	long nLen;

	nLen = 4;

	nRet =  RegSetValueEx(
		LboxReg::hKey,
		lpEntry,
		0,
		REG_DWORD,
		(const unsigned char *)&dwValue,
		nLen
	);

	if ( nRet == ERROR_SUCCESS ) {
		return TRUE;
	}
	else {
		return FALSE;
	}
}
  

  GetBinValue

  

// *********************************************************
// バイナリ値の取得
// *********************************************************
BOOL LboxReg::GetBinValue(LPCTSTR lpEntry, void *Value, int nSize )
{
	DWORD nType;
	LONG nRet;

	nRet = RegQueryValueEx(
		LboxReg::hKey,
		lpEntry,
		NULL,
		&nType,
		(LPBYTE)Value,
		(unsigned long *)(&nSize)
	);

	if ( nRet == ERROR_SUCCESS ) {
		return TRUE;
	}
	else {
		return FALSE;
	}
}
  

  SetBinValue

  

// *********************************************************
// バイナリの登録
// *********************************************************
BOOL LboxReg::SetBinValue(LPCTSTR lpEntry, void *Value, int nLen )
{
	LONG nRet;

	nRet =  RegSetValueEx(
		LboxReg::hKey,
		lpEntry,
		0,
		REG_BINARY,
		(const unsigned char *)Value,
		nLen
	);

	if ( nRet == ERROR_SUCCESS ) {
		return TRUE;
	}
	else {
		return FALSE;
	}
}
  

  Create

  

// *********************************************************
// レジストリキーの作成
// *********************************************************
BOOL LboxReg::Create( HKEY hRoot, LPCTSTR lpSubKey )
{
	LONG nRet;
	HKEY hNew;
	DWORD dwDisposition;

	nRet = RegCreateKeyEx(
		hRoot,
		lpSubKey,
		0,
		NULL,
		REG_OPTION_NON_VOLATILE,
		KEY_ALL_ACCESS,
		NULL,
		&hNew,
		&dwDisposition
	);

	if ( nRet == ERROR_SUCCESS ) {
		if ( dwDisposition == REG_OPENED_EXISTING_KEY ) {
			RegCloseKey( hNew );
		}
		else {
			RegCloseKey( this->hKey );
			this->hKey = hNew;
		}
		return true;
	}
	return false;
}
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[cmstd]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/19 20:51:12
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube