Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rget command with reg_binary as type
#1
Hi, I am having problems getting the value of a registry key. If the type is reg_sz, I get a result. But if it's a reg_binary, its blank.

I don't know what I'm doing wrong Cry
#2
Code:
Copy      Help
RECT r
out rget(r "Toolbar12" "Software\GinDi\QM2\toolbars")
out r.bottom

You should not use str variable to get REG_BINARY value.
#3
Gintaras:

I am getting 0 0 value when running this example.

I wanted the output to be plain text.

Is that possible?
#4
If rget returns 0, it means that the key does not exist, or its data type is not REG_BINARY, or its data size is no equal to sizeof(RECT).

To get data of arbitrary length use Windows API functions. The following is C code. It can be converted to QM.

//_____________________________________

int RGetB(LPSTR key, LPSTR value, void* data, DWORD size, HKEY hive)
{
HKEY hKey; DWORD rc, type=REG_BINARY;
if(RegOpenKeyEx(hive, key, 0, KEY_QUERY_VALUE, &hKey)) return 0;
rc=RegQueryValueEx(hKey, value, 0, &type, (LPBYTE)data, &size);
RegCloseKey(hKey);
if(rc==0 && type==REG_BINARY) return size; else return 0;
}
#5
I just lost you Cry

Here's a better example. on "Software\Gindi\QM2\toolbars" there is
QM toolbar where the value is binary. How would I get it's value in plain text, if possible, or actual binary value?
#6
Code:
Copy      Help
str s
out rget(s "Toolbar12" "Software\GinDi\QM2\toolbars" 0 "" REG_BINARY)
outb s 16 1

To display binary data, I use function outb. Here it is:
Code:
Copy      Help
;/
function !*ptr nBytes [outchar]

out _s.encrypt(8 _s.fromn(ptr nBytes) "" 1)
if(outchar)
,str s.all(nBytes*3 2 32)
,int i c
,for(i 0 nBytes)
,,c=ptr[i]
,,if(c<32) continue
,,s[i*3+1]=c
,out s
#7
Actually, I found a faster way, less headache.

Went into registry editor and did an export :lol: Shortcut, all I have to do is merge.

Is there a way I can automate this? lmfao!
#8
How difficult is it to get all the entries from a key and save it to a txt file?
#9
Use function RegGetValues. Example:
Code:
Copy      Help
ARRAY(str) a
RegGetValues(a "software\gindi\qm2\settings" 0 1)
int i; str s
for i 0 a.len
,s.formata("%s=%s[]" a[0 i] a[1 i])
s.setfile("$desktop$\test.txt")
run "$desktop$\test.txt"

Only String and DWORD values are correctly retrieved.
#10
What about the other types of values, e.g. REG_SZ, etc.

I back up my registry keys all the time manually, would be nice to do it automatically.
#11
To backup/restore registry keys, can be used regedit. Google for regedit command line.

run "regedit.exe" "/E ''key'' ''HKEY_CURRENT_USER\parentkey''"
#12
Code:
Copy      Help
Windows Registry Editor Version 5.00

;Neowin Without Text by Herby
[HKEY_CLASSES_ROOT\CLSID\{00000000-5841-0000-0000-000000000002}]
"InfoTip"=""
"NeverShowExt"=""
@=""

[HKEY_CLASSES_ROOT\CLSID\{00000000-5841-0000-0000-000000000002}\DefaultIcon]
@="%Program Files%\\Yahoo!\Messenger\\YahooMessenger.exe"

[HKEY_CLASSES_ROOT\CLSID\{00000000-5841-0000-0000-000000000002}\Shell]

[HKEY_CLASSES_ROOT\CLSID\{00000000-5841-0000-0000-000000000002}\Shell\00]
@="&Yahoo Messanger"

[HKEY_CLASSES_ROOT\CLSID\{00000000-5841-0000-0000-000000000002}\Shell\00\Command]
@="C:\\Program Files\\Yahoo!\Messenger\\YahooMessenger.exe"



[HKEY_CLASSES_ROOT\CLSID\{00000000-5841-0000-0000-000000000002}\ShellFolder]
"Attributes"=hex:00,00,00,00

;Add Neowin to Desktop
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{00000000-5841-0000-0000-000000000002}]

////this little regedit puts a yahoo messenger icon on your desktop with no text for the icon i would like to do this with qm some how, can this be done?


////is it possible to refresh the desktop with qm?..... sometimes when ur installing an APP it will refresh the desktop icons.. it would be nice to be able to do this with qm Big Grin
#13
Converting it to QM code (rset) requires quite much time and some knowledge. Easier would be to run this reg file.

To update desktop, use this code:
Code:
Copy      Help
str sf.expandpath("$desktop$")
SHChangeNotify(SHCNE_UPDATEDIR SHCNF_PATH sf 0)

SHCNE_UPDATEDIR is 0x00001000
#14
Gintaras Wrote:
Code:
Copy      Help
str s
out rget(s "Toolbar12" "Software\GinDi\QM2\toolbars" 0 "" REG_BINARY)
outb s 16 1

To display binary data, I use function outb. Here it is:
Code:
Copy      Help
;/
function !*ptr nBytes [outchar]

out _s.encrypt(8 _s.fromn(ptr nBytes) "" 1)
if(outchar)
,str s.all(nBytes*3 2 32)
,int i c
,for(i 0 nBytes)
,,c=ptr[i]
,,if(c<32) continue
,,s[i*3+1]=c
,out s


Gintaras, the above example works great. I get 3 lines in debugger window. But I only need the last line. How do I assign this last line to avariable.

Thanks
Denise
#15
Do you need it with all the spaces?
#16
No I do not need the spaces.

Thank you so much!
#17
How do i run this command line in qm?

C:\Windows\regedit.exe /S "C:\Users\Administrator\Desktop\changecolor.reg"
#18
Code:
Copy      Help
run "regedit.exe" "/S ''C:\Users\Administrator\Desktop\changecolor.reg''"
#19
thank you very much
#20
Gintaras,

Let me please extend this post with one additional question.

I understand than in the case of XP-key

Quote:"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU"

REG_BINARY accomodates two values, separated by null characters.

I also understand that I can get the first one using _s.ansi. My question refers on the way to get the second one. I am thinking about modifying your "outb" function to this end, unless you may suggest a faster - simpler way.

Many thanks in advance - Best regards.
#21
I attach herewith my approach. It is tested and it works perfectly. Any advice is still mostly welcome.

Function ReadREG_BGet
Code:
Copy      Help
;/
function~ !*ptr nBytes istrt

;out _s.encrypt(8 _s.fromn(ptr nBytes) "" 1)
str s.all(nBytes*3 2 32)
int i c j
for(i istrt nBytes)
,c=ptr[i]
,s[j]=c
,j=j+1
s.ansi
ret s


Forum Jump:


Users browsing this thread: 1 Guest(s)