Posts: 129
Threads: 38
Joined: May 2006
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
Posts: 12,095
Threads: 142
Joined: Dec 2002
RECT r
out rget(r "Toolbar12" "Software\GinDi\QM2\toolbars")
out r.bottom
You should not use str variable to get REG_BINARY value.
Posts: 129
Threads: 38
Joined: May 2006
Gintaras:
I am getting 0 0 value when running this example.
I wanted the output to be plain text.
Is that possible?
Posts: 12,095
Threads: 142
Joined: Dec 2002
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;
}
Posts: 129
Threads: 38
Joined: May 2006
I just lost you
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?
Posts: 12,095
Threads: 142
Joined: Dec 2002
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:
;/
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
Posts: 129
Threads: 38
Joined: May 2006
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!
Posts: 12
Threads: 2
Joined: Nov 2006
How difficult is it to get all the entries from a key and save it to a txt file?
Posts: 12,095
Threads: 142
Joined: Dec 2002
Use function RegGetValues. Example:
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.
Posts: 12
Threads: 2
Joined: Nov 2006
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.
Posts: 12,095
Threads: 142
Joined: Dec 2002
To backup/restore registry keys, can be used regedit. Google for regedit command line.
run "regedit.exe" "/E ''key'' ''HKEY_CURRENT_USER\parentkey''"
Posts: 331
Threads: 60
Joined: May 2006
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
Posts: 12,095
Threads: 142
Joined: Dec 2002
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:
str sf.expandpath("$desktop$")
SHChangeNotify(SHCNE_UPDATEDIR SHCNF_PATH sf 0)
SHCNE_UPDATEDIR is 0x00001000
Posts: 12
Threads: 2
Joined: Nov 2006
Gintaras Wrote: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:
;/
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
Posts: 12,095
Threads: 142
Joined: Dec 2002
Do you need it with all the spaces?
Posts: 129
Threads: 38
Joined: May 2006
No I do not need the spaces.
Thank you so much!
Posts: 331
Threads: 60
Joined: May 2006
How do i run this command line in qm?
C:\Windows\regedit.exe /S "C:\Users\Administrator\Desktop\changecolor.reg"
Posts: 12,095
Threads: 142
Joined: Dec 2002
run "regedit.exe" "/S ''C:\Users\Administrator\Desktop\changecolor.reg''"
Posts: 331
Threads: 60
Joined: May 2006
Posts: 1,058
Threads: 367
Joined: Oct 2007
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.
Posts: 1,058
Threads: 367
Joined: Oct 2007
I attach herewith my approach. It is tested and it works perfectly. Any advice is still mostly welcome.
Function ReadREG_BGet
;/
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
|