topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 4, 2024, 6:14 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Visual Basic 6 App.s in need of a registry addition.  (Read 3558 times)

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 70
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
Visual Basic 6 App.s in need of a registry addition.
« on: May 11, 2023, 06:30 PM »
My code comes from another of my App's ... some code not working in my new app.s is as follows:
Global Const RegODEkey = "Software\Optimal Designs Enterprise\" & ProgramName
ooo

' Set 'tPause' value in Registry
        If CheckRegistryKey(HKEY_CURRENT_USER, RegODEkey) = False Then
          CreateRegistryKey HKEY_CURRENT_USER, RegODEkey
'         SetRegistryValue HKEY_CURRENT_USER, RegODEkey, "tPause", REG_SZ, "20" ... seems ok to start/compile!
          SetRegistryValue RegODEkey, "tPause", tPause.Text
        End If
        tPause.Text = GetRegistryValue(RegODEkey, "tPause", REG_SZ)
        If tPause.Text = "" Then tPause = "20"
ooo

' Write / Create a Registry value.
' Use KeyName = "" for the default value.
' Supports only DWORD, SZ, and BINARY value types.
Sub SetRegistryValue(ByVal hKey As Long, ByVal KeyName As String, ByVal ValueName As String, ByVal KeyType As Integer, value As Variant)
    Dim handle As Long, lngValue As Long
    Dim strValue As String
    Dim binValue() As Byte, length As Long
   
    ' Open the key, exit if not found.
    If mdlRegistryAPI.RegOpenKeyEx(hKey, KeyName, 0, KEY_WRITE, handle) Then Exit Sub
    Select Case KeyType
        Case REG_DWORD
            lngValue = value
            RegSetValueEx handle, ValueName, 0, KeyType, lngValue, 4
        Case REG_SZ
            strValue = value
            RegSetValueEx handle, ValueName, 0, KeyType, ByVal strValue, Len(strValue)
        Case REG_BINARY
            binValue = value
            length = UBound(binValue) - LBound(binValue) + 1
            RegSetValueEx handle, ValueName, 0, KeyType, binValue(LBound(binValue)), length
    End Select
   
    ' Close the key.
    RegCloseKey handle
End Sub


Ideas where my problem is?  My app can be downloaded at goal-driven.net/download/ and choose "Match-n-Freq (v. 6.6) ... 4 mB" ... its free and has VB6 source code with it.