亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? registry.cpp

?? 整人專家之精靈衛士
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//
// Modify by 徐景周,2000.12
// 功能:注冊表存取類
//
#include "stdafx.h"
#include <winreg.h>
#include "Registry.h"

#define CLASS_NAME_LENGTH 255

/* IMPORTANT NOTES ABOUT CREGISTRY:
	
	CRegistry never keeps a key open past the end of a function call.
	This is incase the application crashes before the next call to close
	the registry 
	
	INCLUDE FILES
	"winreg.h" and "afxdisp.h" must be included in "stdafx.h"

	KEY NAMES:
	Key names must not begin with a \ and only absolute strings are accepted
	
*/

CRegistry::CRegistry()
{
	m_hRootKey = HKEY_CURRENT_USER;
	m_bLazyWrite = TRUE;
	m_nLastError = ERROR_SUCCESS;
}

CRegistry::~CRegistry()
{
	ClearKey();
}


BOOL CRegistry::ClearKey()
{
	/* Call CloseKey to write the current key to the registry and close the 
	key. An application should not keep keys open any longer than necessary. 
	Calling CloseKey when there is no current key has no effect.*/

	m_strCurrentPath.Empty();
	m_hRootKey = HKEY_CURRENT_USER;
	m_bLazyWrite = TRUE;
	return TRUE;
}



BOOL CRegistry::SetRootKey(HKEY hRootKey)
{
	// sets the root key
	// make sure to set it to a valid key
	if (hRootKey != HKEY_CLASSES_ROOT &&
			hRootKey != HKEY_CURRENT_USER &&
			hRootKey != HKEY_LOCAL_MACHINE &&
			hRootKey != HKEY_USERS) return FALSE;

	m_hRootKey = hRootKey;
	return TRUE;
}


BOOL CRegistry::CreateKey(CString strKey)
{
	/* Use CreateKey to add a new key to the registry. 
		Key is the name of the key to create. Key must be 
		an absolute name. An absolute key 
		begins with a backslash (\) and is a subkey of 
		the root key. */

	ASSERT(strKey[0] != '\\');
	HKEY hKey;

	DWORD dwDisposition = 0;

	if (::RegCreateKeyEx(m_hRootKey, LPCTSTR(strKey), 0, NULL,
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,
			&dwDisposition)	!= ERROR_SUCCESS) return FALSE;
	
	if (!m_bLazyWrite) ::RegFlushKey(hKey);
	::RegCloseKey(hKey);
	m_strCurrentPath = strKey;
	return TRUE;
}


BOOL CRegistry::DeleteKey(CString strKey)
{
	/* Call DeleteKey to remove a specified key and its associated data, 
	if any, from the registry. Returns FALSE is there are subkeys
	Subkeys must be explicitly deleted by separate calls to DeleteKey.
	DeleteKey returns True if key deletion is successful. On error, 
	DeleteKey returns False. */
	
	// need to open the key first with RegOpenKeyEx
	ASSERT(FALSE); // not yet implemented
	ASSERT(strKey[0] != '\\');

	if (!KeyExists(strKey)) return TRUE;
	if (::RegDeleteKey(m_hRootKey, strKey) != ERROR_SUCCESS) return FALSE;
	return TRUE;
}



BOOL CRegistry::DeleteValue(CString strName)
{
	/* Call DeleteValue to remove a specific data value 
		associated with the current key. Name is string 
		containing the name of the value to delete. Keys can contain 
		multiple data values, and every value associated with a key 
		has a unique name. */

	ASSERT(m_strCurrentPath.GetLength() > 0);
	HKEY hKey;
	LONG lResult;

	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_SET_VALUE, &hKey) != ERROR_SUCCESS) return FALSE;

	lResult = ::RegDeleteValue(hKey, LPCTSTR(strName));
	::RegCloseKey(hKey);

	if (lResult == ERROR_SUCCESS) return TRUE;
	return FALSE;
}


int CRegistry::GetDataSize(CString strValueName)
{
	/* Call GetDataSize to determine the size, in bytes, of 
	a data value associated with the current key. ValueName 
	is a string containing the name of the data value to query.
	On success, GetDataSize returns the size of the data value. 
	On failure, GetDataSize returns -1. */

	HKEY hKey;
	ASSERT(m_strCurrentPath.GetLength() > 0);
	LONG lResult;

	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) return -1;

	DWORD dwSize = 1;
	lResult = ::RegQueryValueEx(hKey, LPCTSTR(strValueName),
		NULL, NULL, NULL, &dwSize);
	::RegCloseKey(hKey);

	if (lResult != ERROR_SUCCESS) return -1;
	return (int)dwSize;
}

DWORD CRegistry::GetDataType(CString strValueName)
{
	HKEY hKey;
	ASSERT(m_strCurrentPath.GetLength() > 0);

	m_nLastError = ::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_QUERY_VALUE, &hKey);

	if (m_nLastError != ERROR_SUCCESS) return 0;

	DWORD dwType = 1;
	m_nLastError = ::RegQueryValueEx(hKey, LPCTSTR(strValueName),
		NULL, &dwType, NULL, NULL);
	::RegCloseKey(hKey);		

	if (m_nLastError == ERROR_SUCCESS) return dwType;

	return 0;
}



int CRegistry::GetSubKeyCount()
{
	/* Call this function to determine the number of subkeys.
		the function returns -1 on error */
	HKEY hKey;
	ASSERT(m_strCurrentPath.GetLength() > 0);

	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) return -1;

	LONG lResult;
	DWORD dwSubKeyCount, dwValueCount, dwClassNameLength,
		dwMaxSubKeyName, dwMaxValueName, dwMaxValueLength;
	FILETIME ftLastWritten;

	_TCHAR szClassBuffer[CLASS_NAME_LENGTH];
		
	dwClassNameLength = CLASS_NAME_LENGTH;
	lResult = ::RegQueryInfoKey(hKey, szClassBuffer, &dwClassNameLength,
		NULL, &dwSubKeyCount, &dwMaxSubKeyName, NULL, &dwValueCount,
		&dwMaxValueName, &dwMaxValueLength, NULL, &ftLastWritten);
				
	::RegCloseKey(hKey);
	if (lResult != ERROR_SUCCESS) return -1;

	return (int)dwSubKeyCount;
}


int CRegistry::GetValueCount()
{
	/* Call this function to determine the number of subkeys.
		the function returns -1 on error */
	HKEY hKey;
	ASSERT(m_strCurrentPath.GetLength() > 0);

	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) return -1;

	LONG lResult;
	DWORD dwSubKeyCount, dwValueCount, dwClassNameLength,
		dwMaxSubKeyName, dwMaxValueName, dwMaxValueLength;
	FILETIME ftLastWritten;

	_TCHAR szClassBuffer[CLASS_NAME_LENGTH];
		
	dwClassNameLength = CLASS_NAME_LENGTH;
	lResult = ::RegQueryInfoKey(hKey, szClassBuffer, &dwClassNameLength,
		NULL, &dwSubKeyCount, &dwMaxSubKeyName, NULL, &dwValueCount,
		&dwMaxValueName, &dwMaxValueLength, NULL, &ftLastWritten);
				
	::RegCloseKey(hKey);
	if (lResult != ERROR_SUCCESS) return -1;

	return (int)dwValueCount;
}


BOOL CRegistry::KeyExists(CString strKey, HKEY hRootKey)
{
	/* Call KeyExists to determine if a key of a specified name exists.
		 Key is the name of the key for which to search. */

	ASSERT(strKey[0] != '\\');
	HKEY hKey;

	if (hRootKey == NULL) hRootKey = m_hRootKey;
	
	LONG lResult = ::RegOpenKeyEx(hRootKey, LPCTSTR(strKey), 0,
		KEY_ALL_ACCESS, &hKey);
	::RegCloseKey(hKey);
	if (lResult == ERROR_SUCCESS) return TRUE;
	return FALSE;
}

BOOL CRegistry::SetKey(CString strKey, BOOL bCanCreate)
{
	/* Call SetKey to make a specified key the current key. Key is the 
		name of the key to open. If Key is null, the CurrentKey property 
		is set to the key specified by the RootKey property.

		CanCreate specifies whether to create the specified key if it does 
		not exist. If CanCreate is True, the key is created if necessary.

		Key is opened or created with the security access value KEY_ALL_ACCESS. 
		OpenKey only creates non-volatile keys, A non-volatile key is stored in 
		the registry and is preserved when the system is restarted. 

		OpenKey returns True if the key is successfully opened or created */

	ASSERT(strKey[0] != '\\');
	HKEY hKey;


	// close the current key if it is open
	if (strKey.GetLength() == 0)
	{
		m_strCurrentPath.Empty();
		return TRUE;
	}

	DWORD dwDisposition;
	if (bCanCreate) // open the key with RegCreateKeyEx
	{
		if (::RegCreateKeyEx(m_hRootKey, LPCTSTR(strKey), 0, NULL, 
			REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,
				&dwDisposition) != ERROR_SUCCESS) return FALSE;
		m_strCurrentPath = strKey;
		if (!m_bLazyWrite) ::RegFlushKey(hKey);
		::RegCloseKey(hKey);	
		return TRUE;
	}

	// otherwise, open the key without creating
	// open key requires no initial slash
	m_nLastError = ::RegOpenKeyEx(m_hRootKey, LPCTSTR(strKey), 0,
		KEY_ALL_ACCESS, &hKey);
	if (m_nLastError != ERROR_SUCCESS) return FALSE;
	m_strCurrentPath = strKey;
	if (!m_bLazyWrite) ::RegFlushKey(hKey);
	::RegCloseKey(hKey);
	return TRUE;
}


BOOL CRegistry::ValueExists(CString strName)
{
	/* Call ValueExists to determine if a particular key exists in 
		the registry. Calling Value Exists is especially useful before 
		calling other TRegistry methods that operate only on existing keys.

		Name is the name of the data value for which to check.
	ValueExists returns True if a match if found, False otherwise. */

	HKEY hKey;
	LONG lResult;
	ASSERT(m_strCurrentPath.GetLength() > 0);

	
	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) return FALSE;

	lResult = ::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
		NULL, NULL, NULL);
	::RegCloseKey(hKey);

	if (lResult == ERROR_SUCCESS) return TRUE;
	return FALSE;
}


void CRegistry::RenameValue(CString strOldName, CString strNewName)
{
	/* Call RenameValue to change the name of a data value associated 
		with the current key. OldName is a string containing the current 
		name of the data value. NewName is a string containing the replacement 
		name for the data value.
		
		If OldName is the name of an existing data value for the current key, 
		and NewName is not the name of an existing data value for the current 
		key, RenameValue changes the data value name as specified. Otherwise 
		the current name remains unchanged.
	*/
	ASSERT(FALSE); // functionality not yet implemented
}




COleDateTime CRegistry::ReadDateTime(CString strName, COleDateTime dtDefault)
{
	/* Call ReadDate to read a date value from a specified data value 
	associated with the current key. Name is the name of the data value to read.
	If successful, ReadDate returns a Delphi TDateTime value. The integral part 
	of a TDateTime value is the number of days that have passed since 12/30/1899. 
	The fractional part of a TDateTime value is the time of day.
	On error, an exception is raised, and the value returned by this function 
	should be discarded. */

	DWORD dwType = REG_BINARY;
	COleDateTime dt;
	DWORD dwSize = sizeof(dt);
	HKEY hKey;

	ASSERT(m_strCurrentPath.GetLength() > 0);
	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_READ, &hKey) != ERROR_SUCCESS) return dtDefault;
	if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
		&dwType, (LPBYTE)&dt, &dwSize) != ERROR_SUCCESS) dt = dtDefault;
	::RegCloseKey(hKey);	
	return dt;
}


double CRegistry::ReadFloat(CString strName, double fDefault)
{
	/* Call ReadFloat to read a float value from a specified 
		data value associated with the current key. Name is the name 
		of the data value to read.
		
		If successful, ReadFloat returns a double value. 
		On error, an exception is raised, and the value returned by 
		this function should be discarded. */

	DWORD dwType = REG_BINARY;
	double d;
	DWORD dwSize = sizeof(d);
	HKEY hKey;

	ASSERT(m_strCurrentPath.GetLength() > 0);
	if (::RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath), 0,
		KEY_READ, &hKey) != ERROR_SUCCESS) return fDefault;

	if (::RegQueryValueEx(hKey, LPCTSTR(strName), NULL,
		&dwType, (LPBYTE)&d, &dwSize) != ERROR_SUCCESS) d = fDefault;
	::RegCloseKey(hKey);	
	return d;
}

CString CRegistry::ReadString(CString strName, CString strDefault)
{
	DWORD dwType = REG_SZ;
	DWORD dwSize = 255;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合小说图片| 色综合久久综合网欧美综合网| 国产一区二区在线影院| av日韩在线网站| 精品国产网站在线观看| 亚洲人一二三区| 麻豆91精品视频| 91国偷自产一区二区三区观看 | 成人免费视频一区二区| 欧美在线色视频| 欧美韩国日本不卡| 久久国产精品99精品国产| 在线国产电影不卡| 国产精品久久久久久久久动漫| 麻豆精品久久久| 久久精品视频一区| 一区二区三区日韩| 91麻豆蜜桃一区二区三区| 国产夜色精品一区二区av| 卡一卡二国产精品 | www.亚洲精品| 国产欧美va欧美不卡在线| 美国十次了思思久久精品导航| 欧美少妇bbb| 一区二区在线观看av| 91麻豆免费在线观看| 国产精品久久久久久久蜜臀| 粉嫩av亚洲一区二区图片| 久久综合久久鬼色中文字| 激情久久五月天| 精品理论电影在线| 久久99国产精品久久99| 欧美精品一区二| 精品一区二区在线看| 精品国产成人在线影院| 久久成人羞羞网站| 国产亚洲精品7777| 粉嫩高潮美女一区二区三区| 日韩一区中文字幕| 欧美在线高清视频| 午夜精品久久久久久久99水蜜桃| 7799精品视频| 韩国精品主播一区二区在线观看| wwww国产精品欧美| 国产aⅴ综合色| 亚洲免费在线看| 欧美精品第1页| 激情文学综合丁香| 国产精品久久久久aaaa| 色狠狠一区二区三区香蕉| 图片区日韩欧美亚洲| 日韩欧美亚洲另类制服综合在线| 国产一区二区三区在线观看精品| 国产精品伦理一区二区| 欧美色综合久久| 天堂va蜜桃一区二区三区 | 91电影在线观看| 亚洲成va人在线观看| 精品国产伦一区二区三区观看方式 | 国内外精品视频| 国产精品久久毛片a| 欧美午夜电影网| 免费人成在线不卡| 国产精品天干天干在观线| 色综合激情久久| 蜜桃av一区二区| 中文字幕中文在线不卡住| 欧美日韩国产系列| 国产jizzjizz一区二区| 亚洲国产日产av| 欧美极品美女视频| 在线成人免费观看| www.日韩av| 久久国产精品免费| 亚洲狼人国产精品| 久久久久久久久久久久电影| 色偷偷久久人人79超碰人人澡| 麻豆成人久久精品二区三区红| 亚洲欧洲无码一区二区三区| 91精品婷婷国产综合久久| 国产a久久麻豆| 免费在线视频一区| 综合欧美亚洲日本| 久久综合色婷婷| 欧美撒尿777hd撒尿| 成人免费视频免费观看| 久久激情综合网| 亚洲成a人在线观看| 亚洲日本va在线观看| 国产亚洲精久久久久久| 在线播放91灌醉迷j高跟美女| 国产v综合v亚洲欧| 激情小说欧美图片| 日韩高清在线观看| 亚洲国产一区视频| 亚洲免费在线视频一区 二区| 国产三级久久久| 久久久久久久久久电影| 欧美一级高清片在线观看| 欧美亚男人的天堂| 99re6这里只有精品视频在线观看| 国内成人免费视频| 六月丁香综合在线视频| 秋霞午夜av一区二区三区| 亚洲成a人片综合在线| 亚洲第一在线综合网站| 一区二区三区在线高清| 亚洲免费伊人电影| 亚洲精品视频在线看| 国产精品嫩草影院com| 国产亚洲精品aa| 亚洲国产精品成人综合色在线婷婷| 精品电影一区二区三区| 久久人人超碰精品| 国产亚洲综合色| 国产精品美女久久久久久久久| 国产欧美日韩精品a在线观看| 国产欧美精品日韩区二区麻豆天美| 久久久美女毛片| 日本一区二区成人在线| 国产精品丝袜黑色高跟| 亚洲图片你懂的| 椎名由奈av一区二区三区| 亚洲精品日韩专区silk| 亚洲福利视频三区| 日韩av电影免费观看高清完整版| 日韩成人免费在线| 国产一区在线视频| 成人午夜激情在线| 91美女蜜桃在线| 678五月天丁香亚洲综合网| 日韩一区二区影院| 国产亚洲综合av| 一区二区三区精品视频| 日本美女视频一区二区| 国产成人精品午夜视频免费| 波多野结衣的一区二区三区| 在线一区二区观看| 欧美一级夜夜爽| 国产无一区二区| 一区二区激情小说| 免费看欧美美女黄的网站| 国产福利一区在线| 色婷婷综合久久久中文一区二区 | 色综合久久88色综合天天免费| 在线亚洲免费视频| 日韩视频中午一区| 国产精品成人一区二区艾草| 五月激情综合婷婷| 成人免费看黄yyy456| 欧美日韩另类一区| 欧美韩国日本一区| 亚洲国产sm捆绑调教视频| 激情都市一区二区| 91免费观看视频在线| 欧美嫩在线观看| 日本一区二区三区在线不卡| 亚洲国产日日夜夜| 粉嫩aⅴ一区二区三区四区五区| 欧美影院一区二区三区| 久久久美女艺术照精彩视频福利播放| 悠悠色在线精品| 国产精品亚洲午夜一区二区三区 | 丝袜美腿亚洲一区| 国产不卡在线一区| 欧美一区二区黄色| 一区二区三区美女| 国产aⅴ综合色| 日韩一级完整毛片| 亚洲一区二区五区| 成人黄色av网站在线| 精品成人a区在线观看| 香蕉久久夜色精品国产使用方法| 成人黄色小视频| 久久综合久久综合久久| 日韩在线一二三区| 91国偷自产一区二区开放时间 | 精品福利在线导航| 午夜伦理一区二区| 色婷婷激情综合| 国产精品久久久久久久久免费桃花 | 欧美激情一区在线| 狠狠色狠狠色合久久伊人| 欧美色综合久久| 亚洲黄色av一区| 成人动漫一区二区| 国产日韩欧美高清在线| 九九九精品视频| 欧美一二三四区在线| 香蕉成人啪国产精品视频综合网| 色老头久久综合| 有坂深雪av一区二区精品| av午夜精品一区二区三区| 亚洲国产精品v| 国产成人自拍高清视频在线免费播放| 日韩区在线观看| 欧美午夜在线观看| 欧美精品一级二级| 午夜精品一区在线观看| 欧美亚洲一区二区在线|