①、DWORD 类型键值的设置
HKEY hKey = NULL;
TCHAR *lpszSubKey = _T("Console");
LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey);
if (lRet == ERROR_SUCCESS) {
DWORD dwValue = 10;
RegSetValueEx(hKey, _T("TestDWORD"), 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
DWORD dwBuffLen = sizeof(DWORD);
BYTE *lpByte = new BYTE[dwBuffLen];
ZeroMemory(lpByte, dwBuffLen);
memcpy(lpByte, &dwValue, dwBuffLen);
RegSetValueEx(hKey, _T("BYTEDWORD"), 0, REG_DWORD, lpByte, dwBuffLen);
delete [] lpByte;
DWORD dwRealValue = 0;
dwBuffLen = sizeof(DWORD);
RegQueryValueEx(hKey, _T("TestDWORD"), NULL, NULL, (LPBYTE)&dwRealValue, &dwBuffLen);
RegCloseKey(hKey);
}
===================================================
②、子键下默认键值的设置:
HKEY hKey = NULL;
TCHAR *lpszSubKey = _T("Console");
LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey);
if (lRet == ERROR_SUCCESS) {
CString strValue = _T("cctry.com");
RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)strValue.GetBuffer(), strValue.GetLength()*sizeof(TCHAR));
strValue.ReleaseBuffer();
BYTE szBuf[20] = {0};
DWORD dwBuffLen = 20;
RegQueryValueEx(hKey, NULL, NULL, NULL, szBuf, &dwBuffLen);
CString strByte;
strByte.Format(_T("%s"), szBuf);
RegCloseKey(hKey);
}
===================================================
③、分享 Vc6Configer 程序源码!
===================================================
※※※ 小作业:
1、大家有时间的话,可以看看 Vc6Configer 工具的源代码!
2、大家有时间的话,可以自己实现一款IE浏览器主页设置工具!
添加上,主页锁定的功能!
HKEY hKey = NULL;
TCHAR *lpszSubKey = _T("Console");
LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey);
if (lRet == ERROR_SUCCESS) {
DWORD dwValue = 10;
RegSetValueEx(hKey, _T("TestDWORD"), 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
DWORD dwBuffLen = sizeof(DWORD);
BYTE *lpByte = new BYTE[dwBuffLen];
ZeroMemory(lpByte, dwBuffLen);
memcpy(lpByte, &dwValue, dwBuffLen);
RegSetValueEx(hKey, _T("BYTEDWORD"), 0, REG_DWORD, lpByte, dwBuffLen);
delete [] lpByte;
DWORD dwRealValue = 0;
dwBuffLen = sizeof(DWORD);
RegQueryValueEx(hKey, _T("TestDWORD"), NULL, NULL, (LPBYTE)&dwRealValue, &dwBuffLen);
RegCloseKey(hKey);
}
===================================================
②、子键下默认键值的设置:
HKEY hKey = NULL;
TCHAR *lpszSubKey = _T("Console");
LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey);
if (lRet == ERROR_SUCCESS) {
CString strValue = _T("cctry.com");
RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)strValue.GetBuffer(), strValue.GetLength()*sizeof(TCHAR));
strValue.ReleaseBuffer();
BYTE szBuf[20] = {0};
DWORD dwBuffLen = 20;
RegQueryValueEx(hKey, NULL, NULL, NULL, szBuf, &dwBuffLen);
CString strByte;
strByte.Format(_T("%s"), szBuf);
RegCloseKey(hKey);
}
===================================================
③、分享 Vc6Configer 程序源码!
===================================================
※※※ 小作业:
1、大家有时间的话,可以看看 Vc6Configer 工具的源代码!
2、大家有时间的话,可以自己实现一款IE浏览器主页设置工具!
添加上,主页锁定的功能!