ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Visual Basic 6 App.s in need of a registry addition.

(1/1)

OptimalDesigns:
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.

Navigation

[0] Message Index

Go to full version