-
Oct 18th, 2009, 01:58 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Registry
I would like to load some registry data into an array. IE, select a key 'SOFTWARE\Microsoft\Windows\' and load all the values into an array.
thanks
Simon Canning
-
Oct 18th, 2009, 03:10 AM
#2
Re: Registry
Simon
Check the 9th post in this link... on how to get the names of all sub keys in the main key... you will have to amend it as per your requirements...
Also here is a small function to read the value of the subkey when you know the subkey... once you get the subkey... you can always load it into an array which I am sure you won't have a problem with...
vb Code:
Private Sub Command1_Click() MsgBox ReadFrmReg("HKEY_CURRENT_USER\Control Panel\Accessibility\StickyKeys\", "Flags") End Sub Private Function ReadFrmReg(KeyPath, SubKeyName) As Variant Dim Registry As Object Set Registry = CreateObject("WScript.Shell") ReadFrmReg = Registry.RegRead(KeyPath & SubKeyName) End Function
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 18th, 2009, 04:59 AM
#3
Re: Registry
Which OS is this for? If Vista or 7 then you may need to run your app under Admin credientials.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Oct 19th, 2009, 12:31 AM
#4
Thread Starter
Frenzied Member
-
Oct 21st, 2009, 02:42 AM
#5
Thread Starter
Frenzied Member
Re: Registry
koolsid, the 9th post is what i am after.
I want to do a recursive search with the keys returned and then have them added into an array.
Can you (or someone else) help me with this?
thanks
-
Oct 21st, 2009, 06:12 AM
#6
Re: Registry
Did you download that example and check it?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 22nd, 2009, 11:49 PM
#7
Thread Starter
Frenzied Member
Re: Registry
yeh, i checked the example. It lists the key selected, but not the subkeys under it as well. That is what i am after. I have tried the code myself, but have had no luck.
Is there some sample code out there to do this?
-
Oct 23rd, 2009, 12:01 AM
#8
Re: Registry
You can build recursive methods that will read the keys on a given level, collect the results, then pass them back to the outer method. As soon as there are no more sub-keys on the given level, the recursion will stop there, it will exit the loop, and let the outer instances, to collect the other subkeys from the upper levels.
Here is a simple example how recursion can be implemented.
Code:
Function AddNumber() As Long
AddNumber = AddNumber + 1
End Function
For sure, this will be an endless loop (as long as the execution didnt reach the upper limit of the Long value type), however this gives you the single idea how a recursive routine will work.
-
Oct 23rd, 2009, 05:14 AM
#9
Re: Registry
check this scripting method, you can of course do the same with API method
http://www.vbforums.com/showthread.php?t=567903
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 25th, 2009, 04:33 AM
#10
Thread Starter
Frenzied Member
Re: Registry
Westconn1: I get an 'object required' at oreg.EnumKey hkey, strkeypath, arrsubkeys
Is there a project with all the working code in it that I can have a look at?
-
Oct 25th, 2009, 04:45 AM
#11
Re: Registry
did you read the last line after the code box?
declare oreg as object in the general section
as the sub is recursive it makes more sense to only call getobject method once
Is there a project with all the working code in it that I can have a look at?
not really i just wrote it in the ide, i can get the code from codebank any time i want it
Last edited by westconn1; Oct 25th, 2009 at 04:54 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 25th, 2009, 06:05 AM
#12
Thread Starter
Frenzied Member
Re: Registry
Code:
declare oreg as object in the general section
Can you give me the exact code to declare this, im a bit confused.
-
Oct 25th, 2009, 06:28 AM
#13
Re: Registry
dim oreg as object
put that in the general section at the top of the code pane
then it is available to all procedures in that code module, and will retain scope between procedures
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 25th, 2009, 09:46 PM
#14
Thread Starter
Frenzied Member
Re: Registry
i still get an error:
Code:
Object variable or with block variable not set
at oreg.EnumKey hkey, strkeypath, arrsubkeys
How can i fix this?
thanks
-
Oct 25th, 2009, 10:37 PM
#15
Re: Registry
0. use option explicit.
1. declare oreg as object in the general section (at the declarations, at the top of your form's code)
2. Set oreg = GetObject(....
3. oreg.EnumKey hkey, strke ...
-
Oct 25th, 2009, 11:53 PM
#16
Thread Starter
Frenzied Member
Re: Registry
Code:
2. Set oreg = GetObject(....
, can you please explain this code line exactly.
-
Oct 26th, 2009, 01:21 AM
#17
Re: Registry
Code:
2. Set oreg = GetObject(....
, can you please explain this code line exactly.
He is saying that you have to use the word Set before the line which begins with oreg = GetObject(
Got it..??
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 26th, 2009, 01:30 AM
#18
Thread Starter
Frenzied Member
-
Oct 26th, 2009, 02:03 AM
#19
Re: Registry
OK...
If your problem is solved, mark this thread as RESOLVED (from Thread Tools in the top of this page). Also, you can rate the posts which helped you a lot...
Good day...
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 26th, 2009, 02:43 AM
#20
Re: Registry
you have to call a recursive procedure with parameters, from some other procedure, i set the oreg object before calling the recursive sub, see the sample code in the 2nd procedure, which demonstrates how to call the main procedure
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 26th, 2009, 03:32 AM
#21
Thread Starter
Frenzied Member
Re: Registry
I am wanting to add all values returned to a string. What character should I use to seperate each key and value?
Basically, I am after a character that will not appear in any registry entries... is there such a character?
-
Oct 26th, 2009, 03:44 AM
#22
Re: Registry
you can use vbnull or vbnullcharacter or even vbnewline would be unlikely
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 26th, 2009, 04:12 AM
#23
Thread Starter
Frenzied Member
Re: Registry
vbnull or vbnullcharacter wont work as they can appear in an item.
Im thinking maybe non ascii characters. How do i create non ascii characters?
-
Oct 27th, 2009, 04:33 AM
#24
Thread Starter
Frenzied Member
Re: Registry
I might ask this in a new thread, as you have answered my first question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|