|
-
Apr 21st, 2003, 04:13 PM
#1
Thread Starter
Addicted Member
Reading Registry Keys and Values
Ok, here is what I am trying to do. I want to either do it in VB6 or preferably VB.NET so either way is going to be helpful.
I need to do two things:
1) I need to read this registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3 but not return a value. What I actually need to return is all of the keys underneath it. IE
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3 will contain all of the printer drivers on your system so they keys would look like:
Code:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\HP LaserJet 5si
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\Canon BJC-300
I want to read those keys so the values I would be looking for in this case would be HP LaserJet 5si & Canon BJC-300.
Now my plan is to append these values to a list box. Once in the list box here is the function I want to perform against them (and yes this is getting exponentionally more difficult).
In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers is a list of all of the printers on the system. In that key there is a key based on the name of the printer & a value "Printer Driver" that will correspond with one of the keys from above.
More or less what I am trying to do is generate a list box of all of the printer drivers installed on the system and from that list generate a list of printers on the system that use that particular driver.
Is this do able with VB and can anyone point me in the right direction.
I can be reached on here. AOL IM jimmjr19 or ICQ 6262404 if you have any questions or advice.
Thanks,
Jim
-
Apr 21st, 2003, 05:09 PM
#2
I am not too fluent with the APIs for the registry, but I know you can
enumerate the keys of a particular hive. This way you can build your list.
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 
-
Apr 21st, 2003, 05:17 PM
#3
Thread Starter
Addicted Member
Do you have any links, etc... to point me in the right direction?
-
Apr 21st, 2003, 05:21 PM
#4
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 
-
Apr 21st, 2003, 07:50 PM
#5
Thread Starter
Addicted Member
I want to write this for VB6 ( I am learning VB right now and am starting with VB .NET.
This is the code I have now:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Cnt As Integer
Dim RegKey As RegistryKey = Registry.CurrentUser.CreateSubKey( _
"Software")
Dim SubKeys() As String = RegKey.GetSubKeyNames()
Dim DriverAdd As String
If SubKeys.Length > 0 Then
For Cnt = 0 To SubKeys.Length - 1
DriverAdd = (SubKeys(Cnt))
lbDrivers.Items.Add(DriverAdd)
Next Cnt
End If
End Sub
Which is modified and pieced together from the ALLApi website. lbDrivers is a listbox. When you click the button it populates the contents of the listbox with all of the subkeys from HKCU\Software. Since I want to write this in VB6 I went back to the website to get the syntax for it and was first A) shocked and the length of code but also ran into a brick wall because when I paste it into a few form most of the syntax is in red and none of it will compile, without editing any of it yet.
If anyone could point me in the right direction I would greatly appreciate it.
Thanks,
Jim
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
|