INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Reading And Writing To The Registry (VB6)  (Read 11892 times)

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20063
Reading And Writing To The Registry (VB6)
« on: July 06, 2003, 06:31:19 am »

Create A Modual Put This Code In There:

Public Sub CreateKey(Folder As String, Value As String)
   Dim b As Object
   On Error Resume Next
   Set b = CreateObject("wscript.shell")
   b.RegWrite Folder, Value
End Sub
Public Function ReadKey(Value As String) As String
   Dim b As Object
   On Error Resume Next
   Set b = CreateObject("wscript.shell")
   r = b.RegRead(Value)
   ReadKey = r
End Function
Public Sub CreateIntegerKey(Folder As String, Value As Integer)
   Dim b As Object
   On Error Resume Next
   Set b = CreateObject("wscript.shell")
   b.RegWrite Folder, Value, "REG_DWORD"
End Sub
Public Sub DeleteKey(Value As String)
   Dim b As Object
   On Error Resume Next
   Set b = CreateObject("Wscript.Shell")
   b.RegDelete Value
End Sub

===================

In your VB6 Project Just Call The Sub To Read And Write Like This.

Private Sub Command1_Click()
     Call Write_Registry
End Sub

===================

Private Sub Write_Registry()
   On Error GoTo MyError
   Dim MyKey As Variant
   MyKey = "HKCU\Software\JRiver\Media Jukebox\Plugins\Interface\Your Program Name\"
   CreateKey MyKey & "Check1(0)", Check1(0).Value
   CreateKey MyKey & "Check1(1)", Check1(1).Value
   CreateKey MyKey & "Check1(2)", Check1(2).Value
   CreateKey MyKey & "Check1(3)", Check1(3).Value
   CreateKey MyKey & "NumberFound", NewCount(0).Caption
   CreateKey MyKey & "UserControl.BackColor", HScroll1.Value
MyError:
End Sub

Private Sub Read_Registry()
   On Error Resume Next
   Dim MyKey As Variant
   MyKey = "HKCU\Software\JRiver\Media Jukebox\Plugins\Interface\Your Program Name\"
   Check1(0) = ReadKey(MyKey & "Check1(0)")
   Check1(1) = ReadKey(MyKey & "Check1(1)")
   Check1(2) = ReadKey(MyKey & "Check1(2)")
   Check1(3) = ReadKey(MyKey & "Check1(3)")
   NewCount(0).Caption = ReadKey(MyKey & "NumberFound")
   If NewCount(0).Caption = "" Then
       NewCount(0).Caption = 0
   End If
   HScroll1.Value = ReadKey(MyKey & "UserControl.BackColor")
End Sub

=========================

If you Wish To Read The Registry When The User Starts The Plugin Then You Can Use This:

Private Sub UserControl_Initialize()
Call Read_Registry
End Sub

=========================

If you Wish To Write The Registry When The User Ends The Plugin Then You Can Use This:

Private Sub UserControl_Hide()
Call Write_Registry
End Sub


'Games People Play' Charted At 05 In 1975

Listening to: 'Games People Play' from 'The Best Of Spinners' by 'Spinners' on Media Center 9.1
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio, Music
https://MyAAGrapevines.com
https://centercitybbs.com
Fayetteville, NC, USA
Pages: [1]   Go Up