Quote:

so, what's wrong with the pipe-character?
doesn't it write null to the regvalue?




No, for two reasons. First, two pipes together "||" are interpreted as a pipe character in the data rather than a null field.

Second, have you tried using Regedit to add a null entry to the value? It removes it and states that null values are not allowed in REG_MULTI_SZ strings.

You *can* write them. I've done it using StdRegProv and SetMultiStringValue along with my binary data UDFs.

The problem is that the values need to be (sort of) UNICODE.

I got part way through writing the ASCII -> UNICODE conversion stuff, but "real work" has intervened and as this is not something I need right now I have had to drop it.

If anyone would like to pick it up and complete it, here is what I have so far...
Code:
Break ON
$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")

udfAppendMultiSZ(".","HKCU","Software\KiXtart\Testing","RMSZKEY","fooBAR")
If @ERROR "ERROR: " @ERROR ": " @SERROR EndIf

Exit @ERROR

Function udfAppendMultiSZ($sComputer,$sHive,$sKey,$sValueName,$aValues)
Dim $iResult
Dim $aOldValues
Dim $iHiveID
Dim $oReg
Dim $iIndex

Select
Case $sHive="HKCU" or $sHive="HKEY_CURRENT_USER"
$iHiveID=&80000001
Case $sHive="HKLM" or $sHive="HKEY_LOCAL_MACHINE"
$iHiveID=&80000002
Case "Default"
Exit 1
EndSelect

$aOldValues=ReadValue("\\"+$sComputer+"\"+$sHive+"\"+$sKey,$sValueName)
If @ERROR Exit @ERROR EndIf

If VarType($aValues) & 8192 $aValues=Join($aValues,"|") EndIf
If $aOldValues<>"" $aValues=$aOldValues+"|"+$aValues EndIf

$aValues ?

$oReg=GetObject(
"winmgmts:{impersonationLevel=impersonate}!\\"+
+$sComputer
+"\root\default:StdRegProv")
If @ERROR Exit @ERROR EndIf
$aValues=Split($aValues,"|")
For $iIndex=0 to UBound($aValues)
$aValues[$iIndex]=ASCIItoUNICODE($aValues[$iIndex])
Next
Exit $oReg.SetMultiStringValue($iHiveID,$sKey,$sValueName,$aValues)

EndFunction

; Convert an ASCII string to a UNICODE string
Function ASCIItoUNICODE($s)
Dim $oStream,$adTypeBinary,$adTypeText

$adTypeBinary=1
$adTypeText=2

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf


$oStream.Type=$adTypeBinary
$oStream.Open

;$oStream.Write(udfIntToByte(255))
;$oStream.Write(udfIntToByte(254))
While $s <> ""
$oStream.Write(udfIntToByte(Asc($s)))
$oStream.Write(udfIntToByte(0))
$s=SubStr($s,2)
Loop
; Write end of string sentinel
$oStream.Write(udfIntToByte(0))
$oStream.Write(udfIntToByte(0))
$oStream.SetEOS

$oStream.Position=0

$ASCIItoUNICODE=$oStream.Read($oStream.Size)
$oStream.Close
"Data type now: " VarTypeName($ASCIItoUNICODE) ?
Exit 0

EndFunction

; Convert a single integer to a byte array
Function udfIntToByte($i)
Dim $oStream,$adTypeBinary,$adTypeText

$adTypeBinary=1
$adTypeText=2

$oStream=CreateObject("ADODB.Stream")
If @ERROR Exit @ERROR EndIf

$i=CInt($i) & 255

$oStream.Type=$adTypeText
$oStream.CharSet="unicode"
$oStream.Open
$oStream.WriteText(" "+Chr($i))
$oStream.Position=0
$oStream.Type=$adTypeBinary

If $i
$oStream.Position=$oStream.Size-2
Else
$oStream.Position=$oStream.Size-1
EndIf
$udfIntToByte=$oStream.Read(1)
$oStream.Close
Exit 0

EndFunction



The problem is that the ASCIItoUNICODE function converts the string OK, but because it ends up as a BYTE ARRAY the .SetMultiStringValue method rejects the data.

I've also tried reading the data back from the converter using .ReadText with a charset of Unicode. While this returns a string is appears to get set back to an ASCII type which kind of defeats the object.