Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difficult Registry Question

Status
Not open for further replies.

slwolf8

Technical User
Apr 23, 2001
82
US
I was just looking at the FAQ article on getting values from any location in the registry (using an API call). I need to adapt the code to check for the existence of a key in a specified location rather than the getting the value of a key.

Specifically, I wish to check HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Devices to look for the existence of a certain printer (key) named "DPFPrint". Is this possible?
 
Not sure about API calls, but I found this somewhere and it helped me out.

Add Windows Script Host Object Model to your project refference.
Code:
Private Sub CekValue()
Dim wScript As IWshRuntimeLibrary.WshShell
Set wScript = New IWshRuntimeLibrary.WshShell
Dim bKey
On Error GoTo TheTrap
bKey = wScript.RegRead("HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Devices\DPFPrint")
MsgBox "Found"
Exit Sub
TheTrap:
MsgBox "Not found."
Exit Sub
End Sub

Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top