QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: pinology on October 26, 2018, 12:08:49 am
-
does anyone know how to read a couple of registry keys that had my program place there using a .bat file shell. but now how do I have it read them back. I want to be able to input the values I placed there into my qb64 program as a variable. Any ideas would be greatly appreciated
-
Here: http://www.qb64.org/wiki/Windows_Registry_Access
-
Thanks for the reply but i'm not trying to do all that. What I did was added a hklm\software key with the type REG_BINARY using a shell to cmd /c. I was then able to go to the command prompt from windows and do a reg query and find it. now I just want to know if there is a way using either a shell or creating a .bat file to pass my one data field in the registry as a variable to a qb64 program?
-
REGEDIT's /E switch can be used to export a registry key:
REGEDIT /E d:\path\filename.REG "HKEY_XXXX\Whatever Key"
This will write the registry key "HKEY_XXXX\Whatever Key" and its subkeys to a file named d:\path\filename.REG
The resulting file will contain the entries in the format "key"="value", which can be stripped and parsed.
-
ok thanks i'll give that a shot. i'm assuming I would have to use notepad and save those lines as a .bat file and have my qb program shell to it. regedit isn't a qb function is it? Thanks for your help!!!
-
You should be able to just shell to it from QB64 itself.
SHELL "REGEDIT /E .\temp.REG " + CHR$(34) + "HKEY_....whatever" + CHR$(34)
OPEN "temp.REG" FOR INPUT AS #1
... and parse from there.
-
cool got it thanks!!!!
-
How goes it mcneil,
tried a few different ways of using your lines to no avail
i'll show you what I get when I reg query from the command prompt and one of the ways I tried and hopefully you can tell me what I am doing wrong
from the command prompt
Microsoft Windows [Version 10.0.17134.285]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>REG QUERY HKLM\Software\Dungeons /v data /t REG_BINARY
HKEY_LOCAL_MACHINE\Software\Dungeons
data REG_BINARY FE340EAD
End of search: 1 match(es) found.
C:\WINDOWS\system32>
now it is that fe340ead that I want to be able to input into my program as a variable and work with it from there
one of the ways I tried
DIM dung AS STRING * 50
SHELL "REGEDIT /E \temp.REG " + CHR$(34) + "HKLM\Software\Dungeons /v data /t REG_BINARY" + CHR$(34)
OPEN "temp.reg" FOR INPUT AS #1
DO
LINE INPUT #1, dung
LOOP UNTIL EOF(1)
CLOSE #1
-
Try this version:
SHELL _HIDE "REG EXPORT HKLM\Software\7-Zip\ temp.reg"
I'm sorry. REGEDIT /E has apparently been depreciated in newer versions of windows, so it just doesn't work like it used to.
Note: I changed the key to point to a file that was actually in my registery. Just change it as needed, and I think you can get the information you need easily enough in this manner. :)
-
ok thanks i'll give that a shot. do I have to export the temp.reg to the registry like that or could I call it temp.dat and export it right to my qb64 folder. if I have to put it in the registry I will but was kind of hoping I didn't. thanks I appreciate the help!!!!
-
umm I let that run for about 10mins didn't do anything and there is no file in the reg. isn't there any way to have the program shell to the REG QUERY like I did from the command line and be able to assign a variable to the data I want which is the fe340dea without even creating another file ? Have a happy Halloween and thanks again for the try!!
-
The temp.txt should be in your QB64 folder, where you ran it.
If it's working from console, it should be working from SHELL as well.
At the very top of that test, add $CONSOLE to it and watch the output information:
SHELL _HIDE "REG EXPORT HKLM\Software\7-Zip\ temp.reg"
It works like a charm for me, but there may be a Windows permission issue or something causing you problems. 10 minutes is definitely too long for it to run and do nothing; it'll give me a dump of the entire SOFTWARE section in about 15-20 seconds.