📄 regop1.cpp
字号:
/*
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006-2008 Beijing, pengzhen (pengzhenxp@yahoo.com.cn) //
// //
///////////////////////////////////////////////////////////////////////////////
*/
BOOL GetRegBinaryValue(TCHAR* lpstr , DWORD lpstrSize , TCHAR* szInfo , TCHAR* pItemStr)
{
BOOL bOk = FALSE;
//TCHAR szInfo[] = TEXT(REG_DRIVERS_SECTION); // Constructs key names
HKEY hKey;
LONG lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
KEY_ALL_ACCESS, // Desired security access
&hKey); // Opened handle buffer
// lpstr[0] = '\0'; //peng zhen
if (lRet != ERROR_SUCCESS) return bOk;
{
DWORD dwKeyType = REG_BINARY;
DWORD dwKeySize = lpstrSize ;
lRet = RegQueryValueEx(hKey,
pItemStr,
NULL,
&dwKeyType,
(LPBYTE)&lpstr[0],
&dwKeySize);
if (lRet == ERROR_SUCCESS)
{
bOk = TRUE;
}
}
RegCloseKey( hKey );
return bOk;
}
void SetRegBinaryValue(TCHAR* lpstr , DWORD lpstrSize , TCHAR* szInfo , TCHAR* pItemStr)
{
//TCHAR szInfo[] = TEXT(REG_DRIVERS_SECTION); // Constructs key names
HKEY hKey;
LONG lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
NULL, // Address of class name
(DWORD) 0, // Special options flags
KEY_ALL_ACCESS, // Desired security access
NULL, // Key security descriptor
&hKey, // Opened handle buffer
NULL); // What really happened
if (lRet != ERROR_SUCCESS) return;
{
DWORD dwKeyType = REG_BINARY;
DWORD dwKeySize = lpstrSize ;
lRet = RegSetValueEx(
hKey, // Handle to an open key
pItemStr, // Subkey name derivation
0, // Reserved field
dwKeyType, // Returns the field type
(LPBYTE)lpstr, // Returns the field's value
dwKeySize ); // Number of bytes transferred
}
RegCloseKey( hKey );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -