Page 1 of 1 1
Topic Options
#112595 - 2004-01-27 03:52 PM WriteValue, REG_BINARY
FREAKOUT Offline
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 Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hi there and welcome to the board,

you might try to enclose the value in quotes

[edit: sorry, forget my answer ]


Edited by Jochen (2004-01-27 04:19 PM)
_________________________



Top
#112597 - 2004-01-27 04:32 PM Re: WriteValue, REG_BINARY
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jochen, it's a good answer.
question 1, why do you write twice there?
question 2, how do you get AAA value there?
it does not let me do other than "AAA0"

you should read the correct value with kixtart and use that as the value what you write.
_________________________
!

download KiXnet

Top
#112598 - 2004-01-27 04:33 PM Re: WriteValue, REG_BINARY
Richard H. Administrator Offline
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 Offline
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 Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Please take a look here, there is already a posted UDF that works just fine for me.

http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=83554&page=35&view=collapsed&sb=3&o=all&fpart=2&vc=1


Top
#112601 - 2004-01-28 09:36 AM Re: WriteValue, REG_BINARY
Richard H. Administrator Offline
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 Offline
Lurker

Registered: 2004-01-27
Posts: 3
It works ...
Thanks for the replies !

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 84 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.06 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org