Jul 5th, 2008, 08:22 AM
#1
Thread Starter
Lively Member
[ Resolved]Read from registry
Hello i need code how to read from registry.
so for example i got HKEY_LOCAL_MACHINE\software\myapp\important\name
So i need to read the value of "name" and write it on label
ty
Last edited by lulzoralot; Jul 6th, 2008 at 05:41 AM .
Jul 5th, 2008, 09:28 AM
#2
Re: Read from registry
Hai Lulzorlot,
I normally use API methods for reading form the registry.
the api's are
RegOpenKeyEx() - First you need to open that key HKEY_LOCAL_MACHINE\software\myapp\important\name
RegQueryValueEx() - This api return that value you wanted.
If you search the code bank of VBF, you have many examples there.
Also, there are few vbnative function also to read and write to the reg. but i am not much with them
Jul 5th, 2008, 12:30 PM
#3
Re: Read from registry
Those vbnative functions only read/write to the VB and VBA Programs Settings hive.
GetSetting/SaveSetting
HKEY_CURRENT_USER\Software\VB and VBA Program Settings
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
Jul 5th, 2008, 12:51 PM
#4
Re: Read from registry
Yah rob,
tx for remembering that.
Jul 5th, 2008, 05:24 PM
#5
Thread Starter
Lively Member
Re: Read from registry
Hello i fuond this module.
But how can i use it.I mean how can i read from registry
i need to read value of HKEY_LOCAL_MACHINE\software\myapp\important\name
ty
Attached Files
Jul 5th, 2008, 11:05 PM
#6
Re: Read from registry
Attached is the class I wrote to deal with the registry. It would handle what you ask like this:
Code:
Public Sub Sample()
Dim reg As clsRegistry
Dim strName As String
Set reg = New clsRegistry
strName = reg.ReadString("Software\MyApp\Important", "Name", "", rrLocalMachine)
Set reg = Nothing
MsgBox strName
End Sub
Attached Files
Jul 6th, 2008, 01:53 AM
#7
Member
Re: Read from registry
this is my piece of code which I had used in my application and it is working fine...
vb Code:
Private Function RegKeyRead(strPath As String) As String
Dim objCreate As Object
Set objCreate = CreateObject("wscript.shell")
RegKeyRead = objCreate.RegRead(strPath)
End Function
vb Code:
Private Sub RegKeyWrite(strRegPath As String, strRegNewVal As String)
Dim objCreate As Object
Set objCreate = CreateObject("wscript.shell")
objCreate.RegWrite strRegPath, strRegNewVal, "REG_SZ"
End Sub
Please note that if you give strRegPath as a new value which is not in Regedit, it will create the same and mainly this is for "REG_SZ".
Jul 6th, 2008, 05:40 AM
#8
Thread Starter
Lively Member
Jul 6th, 2008, 02:05 PM
#9
Re: Read from registry
Originally Posted by
sivagk
this is my piece of code which I had used in my application and it is working fine...
How do you specify the hive? Note that the OP is trying to read from LOCAL_MACHINE, not CURRENT_USER.
Jul 6th, 2008, 02:09 PM
#10
Re: [ Resolved]Read from registry
Probably have to pass the entire path in the strPath argument.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Outlook
or such I would assume from the look of it.
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
Jul 6th, 2008, 02:14 PM
#11
Re: [ Resolved]Read from registry
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