// // Set Hardware Version // Through the registry entry: // [HKEY_LOCAL_MACHINE/Software/Honeywell/HomeSystem] // HardwareVersion, String // SYSTEMUTILITY_API BOOL SysUtil_SetHardwareVersion(LPWSTR m_StrHardVersion, INT32 bufLen) { long lResult = 0; HKEY hKey; LPCTSTR strSubKeyName = _T("Software//Honeywell//HomeSystem"); LPCTSTR dwKeyName = _T("HardwareVersion"); lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKeyName, 0, 0, &hKey); if(lResult != ERROR_SUCCESS) return FALSE; lResult = RegSetValueEx(hKey, dwKeyName, 0, REG_SZ, (LPBYTE)m_StrHardVersion, bufLen + 2); if(lResult != ERROR_SUCCESS) return FALSE; RegCloseKey(hKey); return TRUE; } // // Set Software Version // Through the registry entry: // [HKEY_LOCAL_MACHINE/Software/Honeywell/HomeSystem] // SoftwareVersion, String // SYSTEMUTILITY_API BOOL SysUtil_SetSoftwareVersion(LPWSTR m_StrSoftVersion, INT32 bufLen) { long lResult = 0; HKEY hKey; LPCTSTR strSubKeyName = _T("Software//Honeywell//HomeSystem"); LPCTSTR dwKeyName = _T("SoftwareVersion"); lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKeyName, 0, 0, &hKey); if(lResult != ERROR_SUCCESS) return FALSE; lResult = RegSetValueEx(hKey, dwKeyName, 0, REG_SZ, (LPBYTE)m_StrSoftVersion, bufLen + 2); if(lResult != ERROR_SUCCESS) return FALSE; RegCloseKey(hKey); return TRUE; } 最近项目用到,放到这里供大家参考。:)