#112595 - 2004-01-27 03:52 PM
WriteValue, REG_BINARY
|
FREAKOUT
Lurker
Registered: 2004-01-27
Posts: 3
|
Hi,
What am I doing wrong here ? I want to write hexadecimal to the reg key "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo" on subkeys "Company" and "UserName" the value "AAA".
It doesn't write it hexadecimal but in a unknown value (false characters) !
$rc=WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo","UserName",AAA,"REG_BINARY") $rc=WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo","Company",AAA,"REG_BINARY")
Thanks !
|
Top
|
|
|
|
#112596 - 2004-01-27 04:13 PM
Re: WriteValue, REG_BINARY
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#112598 - 2004-01-27 04:33 PM
Re: WriteValue, REG_BINARY
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Hmmm...
You have to write it in Unicode.
Give this a try: Code:
$rc=WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo","Company","4100410041000000","REG_BINARY")
|
Top
|
|
|
|
#112599 - 2004-01-28 09:14 AM
Re: WriteValue, REG_BINARY
|
FREAKOUT
Lurker
Registered: 2004-01-27
Posts: 3
|
That's the right solution ! Write the stringin Unicode ... But how can I translate a ASCI string to Unicode ? I would like "dynamically" translate the logged-in user to the $rc=WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo","UserName","THE_LOGGED-IN_USER","REG_BINARY")
Can yoy help me with this ? Thanks
|
Top
|
|
|
|
#112600 - 2004-01-28 09:25 AM
Re: WriteValue, REG_BINARY
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
|
Top
|
|
|
|
#112601 - 2004-01-28 09:36 AM
Re: WriteValue, REG_BINARY
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here is a little UDF to do the conversion for you.
The unicode "set" is hard-coded, but this should work in most cases.
Code:
Function udfStrToRegBin($s) While $s $udfStrToRegBin=$udfStrToRegBin+DecToHex(Asc(Left($s,1)))+"00" $s=SubStr($s,2) Loop $udfStrToRegBin=$udfStrToRegBin+"0000" EndFunction
To use it, just paste the function at the end of your script and call it like this: Code:
$rc=WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo","UserName",udfStrToRegBin("THE_LOGGED-IN_USER"),"REG_BINARY")
|
Top
|
|
|
|
#112602 - 2004-01-28 11:04 AM
Re: WriteValue, REG_BINARY
|
FREAKOUT
Lurker
Registered: 2004-01-27
Posts: 3
|
It works ... Thanks for the replies !
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 84 anonymous users online.
|
|
|