谁有对注册表操作的原程序。 去这里下载吧:http://asp.6to23.com/vcprogram/source/source_main.asp 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #define _WIN32_WINNT 0x4000 #include <stdio.h> #include <tchar.h> #include <windows.h> void _tmain (void) { HKEY hKey = NULL; HKEY hCfgKey = NULL; __try { HW_PROFILE_INFO HwProfile; ULONG ulCurrentConfig = 1; ULONG ulSize = 0; UUID NewGuid; TCHAR RegStr[MAX_PATH]; TCHAR pszRegIDConfigDB[] = TEXT("System\\CurrentControlSet\\Control\\IDConfigDB"); TCHAR pszRegKnownDockingStates[] = TEXT("Hardware Profiles"); TCHAR pszRegCurrentConfig[] = TEXT("CurrentConfig"); TCHAR pszRegHwProfileGuid[] = TEXT("HwProfileGuid"); UCHAR * pszUuidString; // Initialize to all 0s. ZeroMemory(&HwProfile, sizeof(HwProfile)); // Open IDConfigDB key. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, pszRegIDConfigDB, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) { __leave; } // Get current profile sub-key value. ulSize = sizeof(ULONG); if (RegQueryValueEx(hKey, pszRegCurrentConfig, NULL, NULL, (LPBYTE)&ulCurrentConfig, &ulSize) != ERROR_SUCCESS) { __leave; } // Open current profile sub-key. wsprintf(RegStr, TEXT("%s\\%04u"), pszRegKnownDockingStates, ulCurrentConfig); if (RegOpenKeyEx(hKey, RegStr, 0, KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WRITE, &hCfgKey) != ERROR_SUCCESS) { __leave; } // See if HwProfileGuid value exists? ulSize = HW_PROFILE_GUIDLEN * sizeof(TCHAR); if (RegQueryValueEx(hCfgKey, pszRegHwProfileGuid, NULL, NULL, (LPBYTE)&HwProfile.szHwProfileGuid, &ulSize) != ERROR_SUCCESS || HwProfile.szHwProfileGuid[0] == TEXT('\0')) { RPC_STATUS status; // Create a UID for the HwProfileGuid value. if (((status = UuidCreate(&NewGuid)) != RPC_S_OK) && (status != RPC_S_UUID_LOCAL_ONLY)) { __leave; } // Convert the UID to registry entry form. if (UuidToString(&NewGuid, &pszUuidString) == RPC_S_OK) { lstrcpy((LPBYTE)&HwProfile.szHwProfileGuid, TEXT("{")); lstrcat((LPBYTE)&HwProfile.szHwProfileGuid, pszUuidString); lstrcat((LPBYTE)&HwProfile.szHwProfileGuid, TEXT("}")); _strupr((LPBYTE)&HwProfile.szHwProfileGuid); RpcStringFree(&pszUuidString); } // Create or set the HwProfileGuid value. ulSize = (lstrlen(HwProfile.szHwProfileGuid) + 1) * sizeof(TCHAR); if (RegSetValueEx(hCfgKey, pszRegHwProfileGuid, 0, REG_SZ, (LPBYTE)HwProfile.szHwProfileGuid, ulSize) != ERROR_SUCCESS) { __leave; } } // Get current hardware profile. if (GetCurrentHwProfile(&HwProfile)) { _tprintf(TEXT("DockInfo = %d\n"), HwProfile.dwDockInfo); _tprintf(TEXT("Profile Guid = %s\n"), HwProfile.szHwProfileGuid); _tprintf(TEXT("Friendly Name = %s\n"), HwProfile.szHwProfileName); } else { _tprintf(TEXT("Error [0x%x]: GetCurrentHwProfile() failed.\n"), GetLastError()); } } __finally { // Close any open key. if (hCfgKey) RegCloseKey(hCfgKey); if (hKey) RegCloseKey(hKey); } return; } vc6下读取dat数据的问题 求 listen 第二个参数解释的翻译 求助,怎么切换显示的视图? 请教一个小问题; 用c++(vc)能写做网页吗? 字段截取问题 网页分析问题 CTL_CODE宏问题 求助各位!! 每次创建ListView都失败,为什么?(附源码) 很菜的问题:如何在Installshield6.3中给安装程序添加一个背景图片?? 请教线程中控制鼠标的问题
#include <tchar.h>
#include <windows.h> void _tmain (void)
{
HKEY hKey = NULL;
HKEY hCfgKey = NULL; __try
{
HW_PROFILE_INFO HwProfile;
ULONG ulCurrentConfig = 1;
ULONG ulSize = 0;
UUID NewGuid;
TCHAR RegStr[MAX_PATH]; TCHAR pszRegIDConfigDB[] = TEXT("System\\CurrentControlSet\\Control\\IDConfigDB");
TCHAR pszRegKnownDockingStates[] = TEXT("Hardware Profiles");
TCHAR pszRegCurrentConfig[] = TEXT("CurrentConfig");
TCHAR pszRegHwProfileGuid[] = TEXT("HwProfileGuid");
UCHAR * pszUuidString; // Initialize to all 0s.
ZeroMemory(&HwProfile, sizeof(HwProfile)); // Open IDConfigDB key.
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, pszRegIDConfigDB, 0,
KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
{
__leave;
} // Get current profile sub-key value.
ulSize = sizeof(ULONG);
if (RegQueryValueEx(hKey, pszRegCurrentConfig, NULL, NULL,
(LPBYTE)&ulCurrentConfig, &ulSize) != ERROR_SUCCESS)
{
__leave;
} // Open current profile sub-key.
wsprintf(RegStr, TEXT("%s\\%04u"), pszRegKnownDockingStates, ulCurrentConfig);
if (RegOpenKeyEx(hKey, RegStr, 0,
KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WRITE, &hCfgKey) != ERROR_SUCCESS)
{
__leave;
} // See if HwProfileGuid value exists?
ulSize = HW_PROFILE_GUIDLEN * sizeof(TCHAR);
if (RegQueryValueEx(hCfgKey, pszRegHwProfileGuid, NULL, NULL,
(LPBYTE)&HwProfile.szHwProfileGuid, &ulSize) != ERROR_SUCCESS ||
HwProfile.szHwProfileGuid[0] == TEXT('\0'))
{
RPC_STATUS status; // Create a UID for the HwProfileGuid value.
if (((status = UuidCreate(&NewGuid)) != RPC_S_OK) &&
(status != RPC_S_UUID_LOCAL_ONLY))
{
__leave;
} // Convert the UID to registry entry form.
if (UuidToString(&NewGuid, &pszUuidString) == RPC_S_OK)
{
lstrcpy((LPBYTE)&HwProfile.szHwProfileGuid, TEXT("{"));
lstrcat((LPBYTE)&HwProfile.szHwProfileGuid, pszUuidString);
lstrcat((LPBYTE)&HwProfile.szHwProfileGuid, TEXT("}"));
_strupr((LPBYTE)&HwProfile.szHwProfileGuid);
RpcStringFree(&pszUuidString);
} // Create or set the HwProfileGuid value.
ulSize = (lstrlen(HwProfile.szHwProfileGuid) + 1) * sizeof(TCHAR);
if (RegSetValueEx(hCfgKey, pszRegHwProfileGuid, 0, REG_SZ,
(LPBYTE)HwProfile.szHwProfileGuid, ulSize) != ERROR_SUCCESS)
{
__leave;
}
} // Get current hardware profile.
if (GetCurrentHwProfile(&HwProfile))
{
_tprintf(TEXT("DockInfo = %d\n"), HwProfile.dwDockInfo);
_tprintf(TEXT("Profile Guid = %s\n"), HwProfile.szHwProfileGuid);
_tprintf(TEXT("Friendly Name = %s\n"), HwProfile.szHwProfileName);
}
else
{
_tprintf(TEXT("Error [0x%x]: GetCurrentHwProfile() failed.\n"), GetLastError());
}
} __finally
{
// Close any open key.
if (hCfgKey)
RegCloseKey(hCfgKey); if (hKey)
RegCloseKey(hKey);
} return;
}