C 注册表操作大全
1.´ò¿ª¼ü
CString StrKey(%%1);
HKEY m_hKey=%%2;
if
(ERROR_SUCCESS==::RegOpenKeyEx(m_hKey,StrKey,NULL,KEY_ALL_ACCESS,&m_hKey))
{
%%3
}
2.Ìí¼Ó¼ü
CString StrKey(%%1);
HKEY hKey;
DWORD dwDisposition;
if (ERROR_SUCCESS==::RegCreateKeyEx(m_hKey, (LPCTSTR)StrKey,0,NULL, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,&dwDisposition)) {
m_hKey=hKey;
if (dwDisposition==REG_CREATED_NEW_KEY)
{
%%2
}
else if (dwDisposition==REG_OPENED_EXISTING_KEY)
{
%%3
}
}
3.ɾ³ý¼ü
CString StrKey(%%1);
HKEY SrcKey=m_hKey;
char KeyName[256];
int nRes=0;
if (OpenKey(SrcKey,StrKey))
{
nRes=FirstEnumKey(KeyName);
while (nRes)
{
DeleteKey(KeyName);
nRes=NextEnumKey(KeyName);
}
}
if (::RegDeleteKey(SrcKey,StrKey)==ERROR_SUCCESS)
{
C 注册表操作大全
%%2
}
4.ö¾ÙµÚÒ»¸ö¼ü
DWORD dwSize=255;
m_EnumLoop=0;
if
(ERROR_SUCCESS==::RegEnumKeyEx(m_hKey,m_EnumLoop,%%1,&dwSize,NULL,NULL,NULL,NULL))
{
%%2
}
5.ö¾ÙÏÂÒ»¸ö¼ü
DWORD dwSize=255;
m_EnumLoop++;
if
(ERROR_SUCCESS==::RegEnumKeyEx(m_hKey,m_EnumLoop,%%1,&dwSize,NULL,NULL,NULL,NULL))
{
%%2
}
6.»ñÈ¡DWORDÖµ
CString StrChildKey(%%1);
DWORD %%1;
DWORD dwSize=255,dwType=REG_DWORD;
if
(ERROR_SUCCESS==::RegQueryValueEx(m_hKey,StrChildKey,0,&dwType,(BYTE *)(&%%2),&dwSize))
{
%%2
}
7.»ñÈ¡¶þ½øÖÆÖµ
CString StrChildKey(%%1);
DWORD %%1;
DWORD dwSize=255,dwType=REG_BINARY;
if
(ERROR_SUCCESS==::RegQueryValueEx(m_hKey,StrChildKey,0,&dwType,(BYTE *)(&%%2),&dwSize))
{
%%2
}
C 注册表操作大全
8.¶ÁÈ¡×Ö·û´®Öµ
CString StrChildKey(%%1);
CString %%2;
DWORD dwSize=255,dwType=REG_SZ;
char String[256];
if
(ERROR_SUCCESS==::RegQueryValueEx(m_hKey,StrChildKey,0,&dwType,(BYTE *)String,&dwSize))
%%2=CString(String);
9.дÈë×Ö·û´®Öµ
CString StrChildKey(%%1);
CString Value;
CString %%2;
if
(ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_SZ,(BYTE *)(LPCSTR)Value,strlen(Value)+1) )
%%2=CString(Value);
10.дÈë¶þ½øÖÆÖµ
CString StrChildKey(%%1);
const char* %%2;
if
(ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_BINARY,(BYTE *)%%2,strlen(Value)) )
{
%%3
}
11.дÈëDWORDÖµ
CString StrChildKey(%%1);
DWORD %%2;
if
(ERROR_SUCCESS==::RegSetValueEx( m_hKey,(LPCTSTR)StrChildKey,0,REG_DWORD,(BYTE *)&%%2,sizeof(Value)) )
{
%%3
}
12.ÉèÖÃDWORDÖµ
BOOL CRegEdit::SetDwordValue(HKEY Root, LPCTSTR StrKey, LPCTSTR StrChildKey, DWORD Value)
m_hKey=m_RootKey=Root;
C 注册表操作大全
if (CreateKey(StrKey))
{
if (WriteDword(StrChildKey,Value))
{
%%2
}
13.ɾ³ýÖµ
if (ERROR_SUCCESS==RegDeleteValue(m_hKey,%%1))
{
%%2
}
14.¹Ø±Õ¼ü
if (m_hKey!=NULL)
::RegCloseKey(m_hKey);
15.ÁгöÒ»¸ö¼üÏÂËùÓеÄ×Ó¼ü
//#define MAX_KEY_LENGTH 255
TCHAR subKey[MAX_KEY_LENGTH];
DWORD numSubKey=0;
DWORD i;
DWORD sizeSubKey;
TCHAR subKey[MAX_KEY_LENGTH];
RegQueryInfoKey(m_hKey,NULL,NULL,NULL,&numSubKey,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
if (numSubKey)
{
for (i=0; i<numSubKey; i++)
{
subKey[0]='\0';
sizeSubKey=MAX_KEY_LENGTH;
RegEnumKeyEx(m_hKey,i,subKey,&sizeSubKey,NULL,NULL,NULL,NULL); CString %%1=CString(subKey);
}
}
16.ÁгöÒ»¸ö¼üÏÂËùÓеÄÖµ
//#define MAX_KEY_LENGTH 255
//#define MAX_VALUE_NAME 16383
TCHAR achKey[MAX_KEY_LENGTH];
DWORD cbName;
TCHAR achClass[MAX_PATH] = TEXT("");
DWORD cchClassName = MAX_PATH;
C 注册表操作大全
DWORD cSubKeys=0;
DWORD cbMaxSubKey;
DWORD cchMaxClass;
DWORD cValues;
DWORD cchMaxValue;
DWORD cbMaxValueData;
DWORD cbSecurityDescriptor;
FILETIME ftLastWriteTime;
DWORD i, retCode;
TCHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
retCode = RegQueryInfoKey;
(m_hKey,achClass,&cchClassName,NULL,&cSubKeys,&cbMaxSubKey,&cchMaxClass,&cValues,&cchMaxValue,&cbMaxValueData,&cbSecurityDesc
riptor,&ftLastWriteTime);
if (cValues)
{
for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++)
{
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retCode = RegEnumValue(m_hKey, i,achValue,&cchValue,NULL,NULL,NULL,NULL);
if (retCode == ERROR_SUCCESS ){
CString %%1=CString(a …… 此处隐藏:4542字,全部文档内容请下载后查看。喜欢就下载吧 ……
