Ahankhah 发表于 2022-7-6 06:29:42

How to read hexadecimal ( bina

Hi All,
 
as most of you know, (vl-registry-read) is a good function to get data out of windows registry.
 
It works nice for string and decimal number data, but not works correct for hexadecimal (or binary) data.
 
For example, if you issue this:
 

(vl-registry-read "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs" "MRUListEx")
 
you will find '(3) or something similar as the result, but the data exported by Windows "REGEDIT" command on my PC is as seen below:
 
 
How is it possible to get hexadecimal (binary) data from registry.
 
(In the following step, I guess I can convert binary data to strings.)
 
Any help, clues or suggestions are greatly appreciated.

LanloyLisp 发表于 2022-7-6 06:41:59

the results i found to get the value of reg_binary is "wscript.shell".
i tried to manipulate in AutoCAD but the result is error.
 
(vlax-invoke (vlax-create-object "WScript.Shell") 'regread "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\EventLog\\Security\\Sources\\")
 
result
WshShell.RegRead: Invalid root in registry key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security\Sources\".

irneb 发表于 2022-7-6 06:52:33

First, what windows are you using? Some registry keys have been renamed, and in some cases you're not allowed to read some keys. E.g. I can't find the EventLog security sources on my Win7-Pro 64 unless I'm using an admisnistrator account.
 
Also the RegRead from the WScript does not return a path's keys. You'll need to return a specific key. E.g. from the OP's path, in my windows that "folder" contains subfolders as well as keys numbered from 0 through to 149. E.g.
Command: (setq ws (vlax-create-object "WScript.Shell") )#Command: (vlax-invoke ws 'RegRead "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs\\0")(83 0 97 0 109 0 112 0 108 0 101 0 32 0 66 0 111 0 97 0 114 0 100 0 115 0 0 0 112 0 50 0 0 0 0 0 0 0 0 0 0 0 83 97 109 112 108 101 32 66 111 97 114 100 115 46 108 110 107 0 80 0 8 0 4 0 239 190 0 0 0 0 0 0 0 0 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 83 0 97 0 109 0 112 0 108 0 101 0 32 0 66 0 111 0 97 0 114 0 100 0 115 0 46 0 108 0 110 0 107 0 0 0 32 0 0 0)
 
And to save yourself some issue in the future, remember to keep a variable pointing to the object generated by that vlax-create-object function. So you can vlax-release-object later. These ActiveX objects don't get garbage collected like normal lisp variables do, so could end up causing RAM leakage and / or crashes. If you don't keep track of them, there's no way for you to clear them later.

LanloyLisp 发表于 2022-7-6 07:01:36

 
Irneb, Im using windows 7 - premium 64
In my case, the specified key is in the registry.
 

Command: (setq ws (vlax-create-object "WScript.Shell") )#Command: (vlax-invoke ws 'RegRead (vlax-invoke ws 'RegRead "HKLM\\SYSTEM\\MountedDevices\\DosDevices\\C:")WshShell.RegRead: Invalid root in registry key "HKLM\SYSTEM\MountedDevices\DosDevices\C:".Maybe the key I specified is a case that is not allowed to be read.

Lee Mac 发表于 2022-7-6 07:17:41

Reading registry keys from the HKLM hive may require administrator priviledges, or may not be available through Scripting for security reasons.

irneb 发表于 2022-7-6 07:26:54

Yep, if at all possible try to stick with HKCU instead. That usually gives the least trouble as most of them are supposed to be user settings and should thus be (at least) readable by the user's security level. 
The HKLM is not always unavailable, but chances are that lots of those are set to System security level. Therefore you need admin rights to even see them. And most (if not all) companies disallow admin user rights on their PC's to try stopping viruses and such. If the key is only available in HKLM, then try to use something else to get similar data - e.g. if you want to find the drives connected to the PC, perhaps try the FileSystem object's Drives property: http://msdn.microsoft.com/en-us/library/aa242690%28v=VS.60%29.aspx

LanloyLisp 发表于 2022-7-6 07:35:58

Command: (setq sfso (vlax-create-object "Scripting.FileSystemObject"))#Command: (vlax-dump-object (vlax-invoke sfso 'getdrive "H:\\") T); IDrive: Drive Interface; Property values:;   AvailableSpace (RO) = 4.14759e+009;   DriveLetter (RO) = "H";   DriveType (RO) = 1;   FileSystem (RO) = "FAT32";   FreeSpace (RO) = 4.14759e+009;   IsReady (RO) = -1;   Path (RO) = "H:";   RootFolder (RO) = #;   SerialNumber (RO) = -1131567886;   ShareName (RO) = "";   TotalSize (RO) = 8.09918e+009;   VolumeName = "LANLOY 8GB"; No methodsTNow I'm relieved!!
"Wscript.Shell" and "Scripting.FileSystemObject" are the main event of this thread
Especially to both (Irneb and Lee Mac) of you guys.. Thanks a lot.
页: [1]
查看完整版本: How to read hexadecimal ( bina