'registry key
'将一个 DWord 值设置为 Windows 注册表中。
'hLocation:  HKEY_CLASSES_ROOT
'HKEY_CURRENT_USER
'HKEY_LOCAL_MACHINE
'HKEY_USERS
'sSubKeys： 要将保存的子项的名称。
'sValueName： 要查询的值的名称。
'lData： 要存储的值。
'Returns:    %TRUE if successful, %FALSE if failed.
Function FF_SetRegistryDWord(ByVal hLocation as Handle, sSubKeys as CWSTR, sValueName as CWSTR, lData as UInteger) as Long
   
   Dim hKey as HKEY
   Dim zRegName as wString * 1024
   Dim lRegVal as UInteger
   Dim dwType as UInteger
   Dim dwSize as UInteger
   
   lRegVal = lData
   zRegName = sValueName
   If hLocation = 0 Then hLocation = HKEY_CURRENT_USER
   If RegCreateKeyExW(hLocation, RTrim( **sSubKeys, wchr(92)), 0, wchr(0), 0, KEY_WRITE, ByVal 0, @hKey, ByVal 0) = ERROR_SUCCESS Then
      dwSize = SizeOf(lRegVal)
      dwType = REG_DWORD
      If RegSetValueExW(hKey, zRegName, 0, dwType, Cast(UByte Ptr, lRegVal), dwSize) = ERROR_SUCCESS Then Function = True
      RegCloseKey hKey
   End If
End Function

