'registry key
'将一个字符串值设置为 Windows 注册表中。
'   hLocation:  HKEY_CLASSES_ROOT
'               HKEY_CURRENT_USER
'               HKEY_LOCAL_MACHINE
'               HKEY_USERS
'   sSubKeys：  要将保存的子项的名称。
'   sValueName：要查询的值的名称。
'   sData:      要存储的值。
'   Returns:    %TRUE if successful, %FALSE if failed.
Function FF_SetRegistryString(ByVal hLocation as HKEY, sSubKeys as CWSTR, sValueName as CWSTR, sData as CWSTR) as Long
   
   Dim hKey as HKEY
   Dim zRegName as wString * 1024
   Dim zRegVal as wString * 1024
   Dim dwType as UInteger
   Dim dwSize as UInteger

   zRegVal = sData
   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 = Len(zRegVal)*2
      dwType = REG_SZ
      If RegSetValueExW(hKey, @zRegName, 0, dwType, cast(any ptr, VarPtr(zRegVal)), dwSize) = ERROR_SUCCESS Then Function = True
      RegCloseKey hKey
   End If
End Function

