CRegKey类来操作注册表

CRegKey Members 

Visual Studio 2005
2 out of 5 rated this helpful Rate this topic

Methods

Attach

Call this method to attach an HKEY to the CRegKey object by setting the m_hKey member handle to hKey.

Close

Call this method to release the m_hKey member handle and set it to NULL.

Create

Call this method to create the specified key, if it does not exist as a subkey of hKeyParent.

CRegKey

The constructor.

~CRegKey

The destructor.

DeleteSubKey

Call this method to remove the specified key from the registry.

DeleteValue

Call this method to remove a value field from m_hKey.

Detach

Call this method to detach the m_hKey member handle from the CRegKey object and set m_hKey to NULL.

EnumKey

Call this method to enumerate the subkeys of the open registry key.

Flush

Call this method to write all of the attributes of the open registry key into the registry.

GetKeySecurity

Call this method to retrieve a copy of the security descriptor protecting the open registry key.

NotifyChangeKeyValue

This method notifies the caller about changes to the attributes or contents of the open registry key.

Open

Call this method to open the specified key and set m_hKey to the handle of this key.

QueryBinaryValue

Call this method to retrieve the binary data for a specified value name.

QueryDWORDValue

Call this method to retrieve the DWORD data for a specified value name.

QueryGUIDValue

Call this method to retrieve the GUID data for a specified value name.

QueryMultiStringValue

Call this method to retrieve the multistring data for a specified value name.

QueryQWORDValue

Call this method to retrieve the QWORD data for a specified value name.

QueryStringValue

Call this method to retrieve the string data for a specified value name.

QueryValue

Call this method to retrieve the data for the specified value field of m_hKey. Earlier versions of this method are no longer supported and are marked as ATL_DEPRECATED.

RecurseDeleteKey

Call this method to remove the specified key from the registry and explicitly remove any subkeys.

SetBinaryValue

Call this method to set the binary value of the registry key.

SetDWORDValue

Call this method to set the DWORD value of the registry key.

SetGUIDValue

Call this method to set the GUID value of the registry key.

SetKeySecurity

Call this method to set the security of the registry key.

SetKeyValue

Call this method to store data in a specified value field of a specified key.

SetMultiStringValue

Call this method to set the multistring value of the registry key.

SetQWORDValue

Call this method to set the QWORD value of the registry key.

SetStringValue

Call this method to set the string value of the registry key.

SetValue

Call this method to store data in the specified value field of m_hKey. Earlier versions of this method are no longer supported and are marked as ATL_DEPRECATED.

Operators

operator HKEY

Converts a CRegKey object to an HKEY.

operator =

Assignment operator.

Data Members

m_hKey

Contains a handle of the registry key associated with the CRegKey object.

Static Functions

SetValue

Call this method to store data in the specified value field of m_hKey. Earlier versions of this method are no longer supported and are marked asATL_DEPRECATED.



TCHAR szExePath[MAX_PATH] = {0};
if (regKey.Open(HKEY_LOCAL_MACHINE, _T("xxx"), KEY_READ) == ERROR_SUCCESS)
{
TCHAR szPath[1024] = {0};
ULONG ulBytes = 1024;
if (ERROR_SUCCESS == regKey.QueryStringValue(_T("Path"), szPath, &ulBytes))
{
PathRemoveFileSpec(szPath);
PathCombine(szExePath, szPath, _T(".\\xxx.exe"));
}
}

if (regKey.Open(HKEY_CURRENT_USER, szKey, KEY_WRITE) == ERROR_SUCCESS)
{
TCHAR szStrKey[] = _T("xxx");
regKey.SetStringValue(szStrKey, NULL);
}

if (regKey.Create(HKEY_LOCAL_MACHINE, szKey) == ERROR_SUCCESS) 
{
TCHAR szKey[] = _T("cc");//
regKey.SetStringValue(szKey, _T("ffffff"));
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值