Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Attribute VB_Name = "modRegistry"
- Option Explicit
- '_______________________________________________________________
- ' Module: modRegistry
- ' Author: JA
- ' Purpose: Wrapper for Class: clsRegistry
- ' Functions: See Comments above each function for details
- ' SReg_Del_Key Deletes a given registry key
- ' SReg_Del_Metrics_Form Deletes the metrics and view options of a form
- ' SReg_Del_Metrics_ListView Deletes the metrics and options for a ListView
- ' SReg_Del_ODBCData Deletes an ODBC Connection
- ' SReg_Del_Value Deletes a given registry value
- ' SReg_Enm_Sections Enumerates sections of the registry from the given key
- ' SReg_Enm_Values Enumerates values from a given key
- ' SReg_Get_BinaryValue Obtains a binary value from the registry
- ' SReg_Get_ComboBoxContents Retrieves the contents of a ComboBox from the registry
- ' SReg_Get_List Retrieves the list items of a ComboBox or ListBox
- ' SReg_Get_Metrics_Form Retrieves the metrics and view options of a form
- ' SReg_Get_Metrics_ListView Retrieves the metrics and options for a ListView
- ' SReg_Get_NumericValue Returns a numeric value from the registry
- ' SReg_Get_ODBCData Returns a filled SReg_ODBCData object with the corresponding data from the connection
- ' SReg_Get_Program_CompanyName Returns the Company Name from the project (or exe) properties
- ' SReg_Get_Program_Last_Close Returns the last date and time that the program was closed
- ' SReg_Get_Program_Last_Run Returns the last date and time that the program was run
- ' SReg_Get_Program_LastVersion Returns the application version from the registry
- ' SReg_Get_Program_TotalTimesRun Returns the number of times a program has been run
- ' SReg_Get_StringValue Returns a string value from the registry
- ' SReg_Set_BinaryValue Saves a binary value to the registry
- ' SReg_Set_ComboBoxContents Saves the contents of a ComboBox to the registry
- ' SReg_Set_List Saves a list from a ComboBox or a ListBox
- ' SReg_Set_Metrics_Form Stores the metrics of a form an the view options
- ' SReg_Set_Metrics_ListView Stores the metrics and options of a ListView
- ' SReg_Set_NumericValue Adds a numeric value to the registry
- ' SReg_Set_ODBCData Creates/Updates an ODBC Connection
- ' SReg_Set_Program_Info Stores various Information about a program
- ' SReg_Set_StringValue Adds a string to the registry
- ' SReg_Xtr_AssociateFileType Associates a program with a file type
- ' SReg_Xtr_GetDefaultApp Returns the defualt application to launch a specified file
- ' SReg_Xtr_GetFileType Descriptive File Type
- ' Comments: Requires clsRegistry
- '_______________________________________________________________
- Public Type SReg_RetVal
- strKeyName As String
- varKeyValue As Variant
- End Type
- Public SReg_Values_Arr() As SReg_RetVal
- Public SReg_Sections_Arr() As Variant
- Public SReg_bytArr() As Byte
- Public Enum SReg_ODBC_ServerType
- sReg_ST_CRDB2 = 0
- sReg_ST_CRInformix = 1
- sReg_ST_CROracle7 = 2
- sReg_ST_CRSQLBase = 3
- sReg_ST_CRSybaseSystem10 = 4
- sReg_ST_FoxProVFP_DBF = 5
- sReg_ST_MSAccess_MDB = 6
- sReg_ST_MSdBase_DBF = 7
- sReg_ST_MSdBaseVFP_DBF = 8
- sReg_ST_MSExcel_XLS = 9
- sReg_ST_MSFoxPro_DBF = 10
- sReg_ST_MSODBCforOracle = 11
- sReg_ST_MSParadox_DB = 12
- sReg_ST_MSText_TXT_CSV = 13
- sReg_ST_MSVisualFoxPro_DBF = 14
- sReg_ST_MSVisualFoxPro_General = 15
- sReg_ST_SQLServer = 16
- End Enum
- Public Type SReg_ODBCData
- blnLocal As Boolean
- blnTrustedConnection As Boolean
- enmSReg_ODBC_ServerType As SReg_ODBC_ServerType
- strConnectionName As String
- strDatabase As String
- strDriver As String
- strDescription As String
- strLastUser As String
- strServer As String
- End Type
- '
- ' Module: modRegistry.bas
- ' Function: SReg_Del_Key
- ' Type: Public
- ' By: JA
- ' Desc: Deletes a given registry key
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to delete
- ' strMsgBoxTitle Optional Value: Title to use in error MsgBox's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Key not deleted
- ' 1 Key deleted successfully
- ' Note: !! Warning : You probably don't want to run the example !!
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Del_Key(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Del_Key(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce")
- Public Function SReg_Del_Key(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Del_Key 'initiate error handler
- SReg_Del_Key = 0 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .DeleteKey
- End With
- SReg_Del_Key = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Del_Key: 'error handler
- SReg_Del_Key = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Del_Key & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Del_Key" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Del_Metrics_Form
- ' Type: Public
- ' By: JA
- ' Desc: Deletes the metrics and view options of a form
- ' Inputs: enmClassKey selected registry key
- ' frmForm form to delete values for
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not deleted
- ' 1 Information deleted successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Del_Metrics_Form(HKEY_LOCAL_MACHINE, Form1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Del_Metrics_Form(HKEY_LOCAL_MACHINE, Form1)
- Public Function SReg_Del_Metrics_Form(enmClassKey As ERegistryClassConstants, _
- frmForm As Form, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Del_Metrics_Form 'initiate error handler
- SReg_Del_Metrics_Form = 0 'set default return
- Dim strS_Reg_Path_Form As String
- strS_Reg_Path_Form = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name
- SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "WindowState"
- SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Left"
- SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Top"
- SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Width"
- SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Height"
- SReg_Del_Key enmClassKey, strS_Reg_Path_Form
- SReg_Del_Metrics_Form = 1
- Exit Function
- err_SReg_Del_Metrics_Form: 'error handler
- SReg_Del_Metrics_Form = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Del_Metrics_Form & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Del_Metrics_Form" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Del_Metrics_ListView
- ' Type: Public
- ' By: JA
- ' Desc: Deletes the metrics and options for a ListView
- ' Inputs: enmClassKey selected registry key
- ' frmForm form where ListView resides
- ' lvwListView name of ListView
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not deleted
- ' 1 Information deleted successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Del_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Del_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1)
- Public Function SReg_Del_Metrics_ListView(enmClassKey As ERegistryClassConstants, _
- frmForm As Form, _
- lvwListView As ListView, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Del_Metrics_ListView 'initiate error handler
- SReg_Del_Metrics_ListView = 0 'set default return
- Dim lngColIndex As Long
- Dim strS_Reg_Path_ListView As String
- strS_Reg_Path_ListView = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name & "\" & lvwListView.Name
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "AllowColumnReorder"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "Checkboxes"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "FullRowSelect"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "HideSelection"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "HotTracking"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "HoverSelection"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "LabelEdit"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "LabelWrap"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "MultiSelect"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "Sorted"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "SortKey"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "SortOrder"
- With lvwListView.ColumnHeaders
- For lngColIndex = 1 To lvwListView.ColumnHeaders.Count
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text, "Alignment"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text, "Position"
- SReg_Del_Value enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text, "Width"
- Next lngColIndex
- SReg_Del_Key enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text
- SReg_Del_Key enmClassKey, strS_Reg_Path_ListView
- End With
- Exit Function
- err_SReg_Del_Metrics_ListView: 'error handler
- SReg_Del_Metrics_ListView = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Del_Metrics_ListView & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Del_Metrics_ListView" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Del_ODBCData
- ' Type: Public
- ' By: JA
- ' Desc: Deletes an ODBC Connection
- ' Inputs: blnLocal Local Variable: if 'True" then HKEY_LOCAL_MACHINE else HKEY_CURRENT_USER
- ' strConnectionName Name of connection
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns
- ' 1 Success
- ' 0 Nothing to do
- ' -1 Internal Function Error
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Del_ODBCData(True, "MyConnection", "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Del_ODBCData(True, "MyConnection")
- Public Function SReg_Del_ODBCData(blnLocal As Boolean, _
- strConnectionName As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Del_ODBCData 'initiate error handler
- SReg_Del_ODBCData = 0 'set default return
- Dim enmLocalClassKey As ERegistryClassConstants
- Dim strODBCINI As String
- strODBCINI = "SOFTWARE\ODBC\ODBC.INI\"
- Select Case blnLocal
- Case True: enmLocalClassKey = HKEY_CURRENT_USER
- Case False: enmLocalClassKey = HKEY_LOCAL_MACHINE
- End Select
- SReg_Del_Value enmLocalClassKey, strODBCINI & "ODBC Data Sources", strConnectionName
- SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Database"
- SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Description"
- SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Driver"
- SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "LastUser"
- SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Server"
- SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Trusted_Connection"
- SReg_Del_Key enmLocalClassKey, strODBCINI & strConnectionName
- SReg_Del_ODBCData = 1
- Exit Function
- err_SReg_Del_ODBCData: 'error handler
- SReg_Del_ODBCData = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Del_ODBCData & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Del_ODBCData" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Del_Value
- ' Type: Public
- ' By: JA
- ' Desc: Deletes a given registry value
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strSectionValue registry section value (to delete)
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Value not deleted
- ' 1 Value deleted successfully
- ' Note: !! Warning : You probably don't want to run the example !!
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Del_Value(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "Finish Install", "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Del_Value(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "Finish Install")
- Public Function SReg_Del_Value(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strSectionValue As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Del_Value 'initiate error handler
- SReg_Del_Value = 0 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strSectionValue = Trim(strSectionValue)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .SectionKey = strSectionValue
- .DeleteValue
- End With
- SReg_Del_Value = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Del_Value: 'error handler
- SReg_Del_Value = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Del_Value & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Del_Value" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Enm_Sections
- ' Type: Public
- ' By: JA
- ' Desc: Enumerates sections of the registry from the given key
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value(s)
- ' SReg_Sections_Arr() Array to hold returns
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not obtained
- ' 1 Information obtained successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' Dim lngIndex As Long
- ' lngRetVal = SReg_Enm_Sections(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", SReg_Sections_Arr, "", True, True)
- ' If lngRetVal > 0 Then
- ' For lngIndex = 0 To UBound(SReg_Sections_Arr) - 1
- ' List1.AddItem SReg_Sections_Arr(lngIndex)
- ' Next lngIndex
- ' End If
- Public Function SReg_Enm_Sections(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Enm_Sections 'initiate error handler
- SReg_Enm_Sections = 0 'set default return
- Dim cRegistry As New clsRegistry
- Dim strKeys() As String
- Dim lngKeyCount As Long
- Dim lngKeyIndex As Long
- ReDim SReg_Sections_Arr(0)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .EnumerateSections strKeys(), lngKeyCount
- ReDim SReg_Sections_Arr(lngKeyCount)
- For lngKeyIndex = 1 To lngKeyCount
- SReg_Sections_Arr(lngKeyIndex - 1) = strKeys(lngKeyIndex)
- Next lngKeyIndex
- End With
- SReg_Enm_Sections = 1
- Exit Function
- err_SReg_Enm_Sections: 'error handler
- SReg_Enm_Sections = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Enm_Sections & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Enm_Sections" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Enm_Values
- ' Type: Public
- ' By: JA
- ' Desc: Enumerates values from a given key
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value(s)
- ' SReg_Sections_Arr() Array to hold returns
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not obtained
- ' 1 Information obtained successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' Dim lngIndex As Long
- ' lngRetVal = SReg_Enm_Values(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", SReg_Values_Arr, "", True, True)
- ' If lngRetVal > 0 Then
- ' For lngIndex = 0 To UBound(SReg_Values_Arr) - 1
- ' List1.AddItem SReg_Values_Arr(lngIndex).strKeyName & " - " & SReg_Values_Arr(lngIndex).varKeyValue
- ' Next lngIndex
- ' End If
- Public Function SReg_Enm_Values(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- ByRef SReg_Values_Arr() As SReg_RetVal, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Enm_Values 'initiate error handler
- SReg_Enm_Values = 0 'set default return
- Dim cRegistry As New clsRegistry
- Dim strValues() As String
- Dim lngKeyCount As Long
- Dim lngKeyIndex As Long
- ReDim SReg_Values_Arr(0)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .EnumerateValues strValues(), lngKeyCount
- ReDim SReg_Values_Arr(lngKeyCount)
- For lngKeyIndex = 1 To lngKeyCount
- SReg_Values_Arr(lngKeyIndex - 1).strKeyName = strValues(lngKeyIndex)
- SReg_Values_Arr(lngKeyIndex - 1).varKeyValue = SReg_Get_StringValue(enmClassKey, _
- strSectionKey, _
- strValues(lngKeyIndex))
- Next lngKeyIndex
- End With
- SReg_Enm_Values = 1
- Exit Function
- err_SReg_Enm_Values: 'error handler
- SReg_Enm_Values = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Enm_Values & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Enm_Values" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_BinaryValue
- ' Type: Public
- ' By: JA
- ' Desc: Obtains a binary value from the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strSectionValue registry section value
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' SReg_bytArr = SReg_Get_BinaryValue(HKEY_LOCAL_MACHINE, "My Company\My Application\Settings", "Color Settings", "", True, True)
- ' -OR-
- ' SReg_bytArr = SReg_Get_BinaryValue(HKEY_LOCAL_MACHINE, "My Company\My Application\Settings", "Color Settings")
- Public Function SReg_Get_BinaryValue(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strSectionValue As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Variant
- On Error GoTo err_SReg_Get_BinaryValue 'initiate error handler
- SReg_Get_BinaryValue = Nothing 'set default return
- Dim cRegistry As New clsRegistry
- Dim varRetVal As Variant
- Dim lngIndex As Long
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strSectionValue = Trim(strSectionValue)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .ValueKey = strSectionValue
- varRetVal = .Value
- Select Case .ValueType
- Case REG_BINARY
- For lngIndex = LBound(varRetVal) To UBound(varRetVal)
- SReg_Get_BinaryValue = SReg_Get_BinaryValue & "&H"
- If (lngIndex < &H10) Then SReg_Get_BinaryValue = SReg_Get_BinaryValue & "0"
- SReg_Get_BinaryValue = SReg_Get_BinaryValue & Hex$(varRetVal(lngIndex)) & " "
- Next lngIndex
- Case Else
- SReg_Get_BinaryValue = varRetVal
- End Select
- End With
- Exit Function
- err_SReg_Get_BinaryValue: 'error handler
- SReg_Get_BinaryValue = Nothing 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_BinaryValue & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_BinaryValue" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_ComboBoxContents
- ' Type: Public
- ' By: JA
- ' Desc: Retrieves the contents of a ComboBox from the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to get value
- ' cboCombobox As ComboBox The ComboBox to reference
- ' lngMaxItems As Long Optional Value: Default is -1 (No Limit). Zero or higher will limit the list
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Get_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo, -1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Get_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo)
- Public Function SReg_Get_ComboBoxContents(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- cboComboBox As ComboBox, _
- Optional lngMaxItems As Long = -1, _
- Optional strErr_MsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Get_ComboBoxContents 'initiate error handler
- SReg_Get_ComboBoxContents = 0 'set default return
- Dim strValueKey As String
- Dim lngIndex As Long
- Dim strContents As String
- Dim strRegRetVal As String
- 'Dim lngRetVal As Long
- 'lngRetVal = SReg_Enm_Values(HKEY_CURRENT_USER, "Testing\Combo1", SReg_Values_Arr, "", True, True)
- 'If lngRetVal > 0 Then
- ' For lngIndex = 0 To UBound(SReg_Values_Arr) - 1
- ' cboCombobox.AddItem SReg_Values_Arr(lngIndex).strKeyName & " - " & SReg_Values_Arr(lngIndex).varKeyValue
- ' Next lngIndex
- 'End If
- 'Exit Function
- strRegRetVal = SReg_Get_StringValue(enmClassKey, strSectionKey, "MaxItems")
- If Len(strRegRetVal) > 0 Then
- If IsNumeric(strRegRetVal) Then
- lngMaxItems = strRegRetVal
- Else
- SReg_Get_ComboBoxContents = -2
- Exit Function
- End If
- Else
- SReg_Get_ComboBoxContents = -3
- Exit Function
- End If
- For lngIndex = 1 To lngMaxItems
- strValueKey = lngIndex
- strContents = SReg_Get_StringValue(enmClassKey, strSectionKey, strValueKey)
- If Len(Trim(strContents)) > 0 Then cboComboBox.AddItem strContents
- Next lngIndex
- SReg_Get_ComboBoxContents = 1
- Exit Function
- err_SReg_Get_ComboBoxContents: 'error handler
- SReg_Get_ComboBoxContents = -1 'set internal error return
- Debug.Print Now & " | Function: & SReg_Get_ComboBoxContents & | Error: #" & Err.Number & vbTab & Err.Description 'send message to immediate window
- If blnErr_ShowCritical = True Then 'if we want to show critical messages to the user
- Select Case MsgBox("Error: #" & Err.Number & vbTab & Err.Description & vbTab & _
- vbCrLf & vbCrLf & Now & _
- vbCrLf & vbCrLf & "(Use Ctrl+C to copy this message.)", _
- vbAbortRetryIgnore + vbCritical, _
- strErr_MsgBoxTitle & " [Function: SReg_Get_ComboBoxContents - " & Err.Source & "]")
- Case vbAbort: Exit Function
- Case vbRetry: Resume
- Case vbIgnore: Resume Next
- End Select
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_List
- ' Type: Public
- ' By: JA
- ' Desc: Retrieves the list items of a ComboBox or ListBox
- ' Inputs: enmClassKey selected registry key
- ' ctlControl ComboBox or ListBox
- ' blnRestoreLastPos Optional Value: if 'True' then will select the last selected item
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not obtained
- ' 1 Information obtained successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Get_List(HKEY_LOCAL_MACHINE, ComboBox1, True, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Get_List(HKEY_LOCAL_MACHINE, ComboBox1)
- Public Function SReg_Get_List(enmClassKey As ERegistryClassConstants, _
- ctlControl As Object, _
- Optional blnRestoreLastPos As Boolean, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Get_List 'initiate error handler
- SReg_Get_List = 0 'set default return
- Dim lngListIndex As Long
- Dim strListIndex As String
- Dim lngListCount As Long
- Dim strRegRetVal As String
- Dim lngSelIndex As Long
- Dim strS_Reg_Path_Lists As String
- strS_Reg_Path_Lists = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Lists\" & ctlControl.Name
- strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_Lists, "Max Items")
- If IsNumeric(strRegRetVal) = True Then
- lngListCount = strRegRetVal
- Else
- Exit Function
- End If
- If blnRestoreLastPos = True Then
- strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_Lists, "Curr Item")
- If IsNumeric(strRegRetVal) = True Then lngSelIndex = strRegRetVal
- End If
- Select Case TypeName(ctlControl)
- Case "ComboBox", "ListBox"
- For lngListIndex = 0 To lngListCount - 1
- strListIndex = lngListIndex
- strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_Lists, strListIndex)
- If Len(strRegRetVal) > 0 Then ctlControl.AddItem strRegRetVal
- Next lngListIndex
- End Select
- If blnRestoreLastPos = True Then If lngSelIndex > ctlControl.ListCount Then lngSelIndex = 0
- ctlControl.ListIndex = lngSelIndex
- SReg_Get_List = 1
- Exit Function
- err_SReg_Get_List: 'error handler
- SReg_Get_List = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_List & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_List" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Metrics_Form
- ' Type: Public
- ' By: JA
- ' Desc: Retrieves the metrics and view options of a form
- ' Inputs: enmClassKey selected registry key
- ' frmForm form to obtain values for
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not obtained
- ' 1 Information obtained successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Get_Metrics_Form(HKEY_LOCAL_MACHINE, Form1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Get_Metrics_Form(HKEY_LOCAL_MACHINE, Form1)
- Public Function SReg_Get_Metrics_Form(enmClassKey As ERegistryClassConstants, _
- frmForm As Form, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Get_Metrics_Form 'initiate error handler
- SReg_Get_Metrics_Form = 0 'set default return
- Dim cRegistry As New clsRegistry
- Dim lngForm_WindowState As Long
- Dim lngForm_Left As Long
- Dim lngForm_Top As Long
- Dim lngForm_Width As Long
- Dim lngForm_Height As Long
- Dim strS_Reg_Path_Form As String
- strS_Reg_Path_Form = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strS_Reg_Path_Form
- .ValueType = REG_DWORD
- .ValueKey = "WindowState": lngForm_WindowState = .Value
- .ValueKey = "Left": lngForm_Left = .Value
- .ValueKey = "Top": lngForm_Top = .Value
- .ValueKey = "Width": lngForm_Width = .Value
- .ValueKey = "Height": lngForm_Height = .Value
- End With
- With frmForm
- If lngForm_Width <> 0 Then .Width = lngForm_Width
- If lngForm_Height <> 0 Then .Height = lngForm_Height
- If lngForm_WindowState = 0 Then
- .Move (Screen.Width - .Width) / 2, (Screen.Height - .Height) / 2
- Else
- If lngForm_Left < 0 Then lngForm_Left = (Screen.Width - .Width) / 2
- If (lngForm_Left - -lngForm_Width) > Screen.Width Then lngForm_Left = (Screen.Width - .Width) / 2
- If lngForm_Top < 0 Then lngForm_Top = (Screen.Height - .Height) / 2
- If (lngForm_Top - -lngForm_Height) > Screen.Height Then lngForm_Top = (Screen.Height - .Height) / 2
- .WindowState = lngForm_WindowState
- End If
- If lngForm_Left <> 0 Then .Left = lngForm_Left
- If lngForm_Top <> 0 Then .Top = lngForm_Top
- End With
- SReg_Get_Metrics_Form = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Get_Metrics_Form: 'error handler
- SReg_Get_Metrics_Form = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Metrics_Form & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Metrics_Form" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Metrics_ListView
- ' Type: Public
- ' By: JA
- ' Desc: Retrieves the metrics and options for a ListView
- ' Inputs: enmClassKey selected registry key
- ' frmForm form where ListView resides
- ' lvwListView name of ListView
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not obtained
- ' 1 Information obtained successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Get_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Get_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1)
- Public Function SReg_Get_Metrics_ListView(enmClassKey As ERegistryClassConstants, _
- frmForm As Form, _
- lvwListView As ListView, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Get_Metrics_ListView 'initiate error handler
- SReg_Get_Metrics_ListView = 0 'set default return
- Dim cRegistry As New clsRegistry
- Dim lngColIndex As Long
- Dim varRetVal As Variant
- Dim strS_Reg_Path_ListView As String
- strS_Reg_Path_ListView = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name & "\" & lvwListView.Name
- With cRegistry
- .ClassKey = enmClassKey
- .ValueType = REG_SZ
- End With
- With lvwListView
- cRegistry.SectionKey = strS_Reg_Path_ListView
- cRegistry.ValueKey = "AllowColumnReorder": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .AllowColumnReorder = True Else .AllowColumnReorder = False
- cRegistry.ValueKey = "Checkboxes": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .Checkboxes = True Else .Checkboxes = False
- cRegistry.ValueKey = "FullRowSelect": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .FullRowSelect = True Else .FullRowSelect = False
- cRegistry.ValueKey = "HideSelection": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .HideSelection = True Else .HideSelection = False
- cRegistry.ValueKey = "HotTracking": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .HotTracking = True Else .HotTracking = False
- cRegistry.ValueKey = "HoverSelection": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .HoverSelection = True Else .HoverSelection = False
- cRegistry.ValueType = REG_DWORD
- cRegistry.ValueKey = "LabelEdit": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .LabelEdit = varRetVal
- cRegistry.ValueType = REG_SZ
- cRegistry.ValueKey = "LabelWrap": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .LabelWrap = True Else .LabelWrap = False
- cRegistry.ValueKey = "MultiSelect": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .MultiSelect = True Else .MultiSelect = False
- cRegistry.ValueKey = "Sorted": varRetVal = cRegistry.Value
- If varRetVal = "True" Then .Sorted = True Else .Sorted = False
- cRegistry.ValueType = REG_DWORD
- cRegistry.ValueKey = "SortKey": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .SortKey = varRetVal
- cRegistry.ValueKey = "SortOrder": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .SortOrder = varRetVal
- cRegistry.ValueKey = "View": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .View = varRetVal
- End With
- If lvwListView.ColumnHeaders.Count < 1 Then Exit Function
- With lvwListView.ColumnHeaders
- For lngColIndex = 1 To lvwListView.ColumnHeaders.Count
- cRegistry.SectionKey = strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text
- cRegistry.ValueType = REG_DWORD
- cRegistry.ValueKey = "Alignment": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .Item(lngColIndex).Alignment = varRetVal
- cRegistry.ValueKey = "Position": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .Item(lngColIndex).Position = varRetVal
- cRegistry.ValueType = REG_SZ
- cRegistry.ValueKey = "Width": varRetVal = cRegistry.Value
- If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .Item(lngColIndex).Width = varRetVal
- Next lngColIndex
- End With
- SReg_Get_Metrics_ListView = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Get_Metrics_ListView: 'error handler
- SReg_Get_Metrics_ListView = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Metrics_ListView & | " & frmForm.Name & "." & lvwListView.Name & " Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Metrics_ListView" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_NumericValue
- ' Type: Public
- ' By: JA
- ' Desc: Returns a numeric value from the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strSectionValue registry section value
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Get_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "IconIndex", "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Get_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "IconIndex")
- Public Function SReg_Get_NumericValue(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strSectionValue As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Get_NumericValue 'initiate error handler
- SReg_Get_NumericValue = 0 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strSectionValue = Trim(strSectionValue)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .ValueKey = strSectionValue
- .ValueType = REG_DWORD
- SReg_Get_NumericValue = .Value
- End With
- Set cRegistry = Nothing
- SReg_Get_NumericValue = 1
- Exit Function
- err_SReg_Get_NumericValue: 'error handler
- SReg_Get_NumericValue = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_NumericValue & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_NumericValue" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_ODBCData
- ' Type: Public
- ' By: JA
- ' Desc: Returns a filled SReg_ODBCData object with the corresponding data from the connection
- ' Inputs: blnLocal Local Variable: If True then HKEY_LOCAL_MACHINE else HKEY_CURRENT_USER
- ' strConnectionName Name fo the connection to look for
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim typSReg_ODBCData As SReg_ODBCData
- ' typSReg_ODBCData = SReg_Get_ODBCData(True, "MyConnection", "", True, True)
- ' -OR-
- ' typSReg_ODBCData = SReg_Get_ODBCData(True, "MyConnection")
- Public Function SReg_Get_ODBCData(blnLocal As Boolean, _
- strConnectionName As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As SReg_ODBCData
- On Error GoTo err_SReg_Get_ODBCData 'initiate error handler
- Dim enmLocalClassKey As ERegistryClassConstants
- Dim strRegRetVal As String
- Dim strODBCINI As String
- strODBCINI = "SOFTWARE\ODBC\ODBC.INI\"
- 'clean data
- strConnectionName = Trim(strConnectionName)
- 'validate data
- If Len(strConnectionName) = 0 Then
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & _
- "Connection Name Not Specified"
- 'if we want to show friendly messages to the user
- If blnErr_ShowFriendly Then
- MsgBox "Error: " & "Connection Name Not Specified" & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbInformation, _
- strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
- End If
- Exit Function
- End If
- Select Case blnLocal
- Case True: enmLocalClassKey = HKEY_CURRENT_USER
- Case False: enmLocalClassKey = HKEY_LOCAL_MACHINE
- End Select
- 'get data
- With SReg_Get_ODBCData
- .strConnectionName = strConnectionName
- strRegRetVal = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & "ODBC Data Sources", strConnectionName))
- Select Case UCase(strConnectionName)
- Case "CR DB2": .enmSReg_ODBC_ServerType = sReg_ST_CRDB2
- Case "CR INFORMIX": .enmSReg_ODBC_ServerType = sReg_ST_CRInformix
- Case "CR ORACLE7": .enmSReg_ODBC_ServerType = sReg_ST_CROracle7
- Case "CR SQLBASE": .enmSReg_ODBC_ServerType = sReg_ST_CRSQLBase
- Case "CR SYBASE SYSTEM 10": .enmSReg_ODBC_ServerType = sReg_ST_CRSybaseSystem10
- Case "MICROSOFT FOXPRO VFP DRIVER (*.DBF)": .enmSReg_ODBC_ServerType = sReg_ST_FoxProVFP_DBF
- Case "MICROSOFT ACCESS DRIVER (*.MDB)": .enmSReg_ODBC_ServerType = sReg_ST_MSAccess_MDB
- Case "MICROSOFT DBASE DRIVER (*.DBF)": .enmSReg_ODBC_ServerType = sReg_ST_MSdBase_DBF
- Case "MICROSOFT DBASE VFP DRIVER (*.DBF)": .enmSReg_ODBC_ServerType = sReg_ST_MSdBaseVFP_DBF
- Case "MICROSOFT EXCEL DRIVER (*.XLS)": .enmSReg_ODBC_ServerType = sReg_ST_MSExcel_XLS
- Case "MICROSOFT FOXPRO DRIVER (*.DBF)": .enmSReg_ODBC_ServerType = sReg_ST_MSFoxPro_DBF
- Case "MICROSOFT ODBC FOR ORACLE": .enmSReg_ODBC_ServerType = sReg_ST_MSODBCforOracle
- Case "MICROSOFT PARADOX DRIVER (*.DB )": .enmSReg_ODBC_ServerType = sReg_ST_MSParadox_DB
- Case "MICROSOFT TEXT DRIVER (*.TXT; *.CSV)": .enmSReg_ODBC_ServerType = sReg_ST_MSText_TXT_CSV
- Case "MICROSOFT VISUAL FOXPRO DRIVER (*.DBF)": .enmSReg_ODBC_ServerType = sReg_ST_MSVisualFoxPro_DBF
- Case "MICROSOFT VISUAL FOXPRO DRIVER": .enmSReg_ODBC_ServerType = sReg_ST_MSVisualFoxPro_General
- Case "SQL SERVER": .enmSReg_ODBC_ServerType = sReg_ST_SQLServer
- End Select
- .strDatabase = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Database"))
- .strDescription = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Description"))
- .strDriver = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Driver"))
- .strLastUser = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "LastUser"))
- .strServer = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Server"))
- strRegRetVal = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Trusted_Connection"))
- Select Case UCase(strRegRetVal)
- Case "YES": .blnTrustedConnection = True
- Case Else: .blnTrustedConnection = False
- End Select
- End With
- Exit Function
- err_SReg_Get_ODBCData: 'error handler
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_ODBCData & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_ODBCData" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Program_CompanyName
- ' Type: Public
- ' By: JA
- ' Desc: Returns the Company Name from the project (or exe) properties
- ' Inputs: strMsgBoxTitle Optional Value: Title to use in error MsgBox's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: Internally this is used for registry paths
- ' Example:
- ' Dim strRetVal As String
- ' strRetVal = SReg_Get_Program_CompanyName("", True, True)
- ' -OR-
- ' strRetVal = SReg_Get_Program_CompanyName
- ' strRetVal now contains: "Company Name"
- Public Function SReg_Get_Program_CompanyName(Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Get_Program_CompanyName 'initiate error handler
- SReg_Get_Program_CompanyName = vbNullString 'set default return
- SReg_Get_Program_CompanyName = Trim(App.CompanyName)
- If Len(SReg_Get_Program_CompanyName) < 1 Then SReg_Get_Program_CompanyName = "Miscellaneous"
- Exit Function
- err_SReg_Get_Program_CompanyName: 'error handler
- SReg_Get_Program_CompanyName = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Program_CompanyName & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Program_CompanyName" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Program_Last_Close
- ' Type: Public
- ' By: JA
- ' Desc: Returns the last date and time that the program was closed
- ' Inputs: enmClassKey selected registry key
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim strRetVal As String
- ' strRetVal = SReg_Get_Program_Last_Close(HKEY_LOCAL_MACHINE, "", True, True)
- ' -OR-
- ' strRetVal = SReg_Get_Program_Last_Close(HKEY_LOCAL_MACHINE)
- Public Function SReg_Get_Program_Last_Close(enmClassKey As ERegistryClassConstants, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Get_Program_Last_Close 'initiate error handler
- SReg_Get_Program_Last_Close = vbNullString 'set default return
- Dim strS_Reg_Path_ProgInfo As String
- strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
- SReg_Get_Program_Last_Close = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Last Closed")
- Exit Function
- err_SReg_Get_Program_Last_Close: 'error handler
- SReg_Get_Program_Last_Close = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Program_Last_Close & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Program_Last_Close" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Program_Last_Run
- ' Type: Public
- ' By: JA
- ' Desc: Returns the last date and time that the program was run
- ' Inputs: enmClassKey selected registry key
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim strRetVal As String
- ' strRetVal = SReg_Get_Program_Last_Run(HKEY_LOCAL_MACHINE, "", True, True)
- ' -OR-
- ' strRetVal = SReg_Get_Program_Last_Run(HKEY_LOCAL_MACHINE)
- Public Function SReg_Get_Program_Last_Run(enmClassKey As ERegistryClassConstants, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Get_Program_Last_Run 'initiate error handler
- SReg_Get_Program_Last_Run = vbNullString 'set default return
- Dim strS_Reg_Path_ProgInfo As String
- strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
- SReg_Get_Program_Last_Run = SReg_Get_StringValue(HKEY_CURRENT_USER, strS_Reg_Path_ProgInfo, "Last Run")
- Exit Function
- err_SReg_Get_Program_Last_Run: 'error handler
- SReg_Get_Program_Last_Run = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Program_Last_Run & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Program_Last_Run" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Program_LastVersion
- ' Type: Public
- ' By: JA
- ' Desc: Returns the application version from the registry
- ' Inputs: enmClassKey selected registry key
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: Use this before using 'SReg_Set_Program_Info' to see if the application has been updated
- ' If you change the size of a form in an update you would want to delete the metric settings
- ' and maybe some other options on the first run
- ' Example:
- ' Dim strRetVal As Long
- ' Dim strCurrAppVer As String
- ' strRetVal = SReg_Get_Program_LastVersion(HKEY_LOCAL_MACHINE, "", True, True)
- ' strCurrAppVer = App.Major & "." & App.Minor & "." & App.Revision
- ' If strRetVal <> strCurrAppVer Then
- ' '[insert code here]
- ' End If
- Public Function SReg_Get_Program_LastVersion(enmClassKey As ERegistryClassConstants, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Get_Program_LastVersion 'initiate error handler
- SReg_Get_Program_LastVersion = vbNullString 'set default return
- Dim strAppMajor As String
- Dim strAppMinor As String
- Dim strAppRevision As String
- Dim strS_Reg_Path_ProgInfo As String
- strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
- strAppMajor = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Major")
- strAppMinor = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Minor")
- strAppRevision = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Revision")
- SReg_Get_Program_LastVersion = strAppMajor & "." & strAppMinor & "." & strAppRevision
- Exit Function
- err_SReg_Get_Program_LastVersion: 'error handler
- SReg_Get_Program_LastVersion = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Program_LastVersion & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Program_LastVersion" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_Program_TotalTimesRun
- ' Type: Public
- ' By: JA
- ' Desc: Returns the number of times a program has been run
- ' Inputs: enmClassKey selected registry key
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Get_Program_TotalTimesRun(HKEY_LOCAL_MACHINE, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Get_Program_TotalTimesRun(HKEY_LOCAL_MACHINE)
- Public Function SReg_Get_Program_TotalTimesRun(enmClassKey As ERegistryClassConstants, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Get_Program_TotalTimesRun 'initiate error handler
- SReg_Get_Program_TotalTimesRun = 0 'set default return
- Dim strS_Reg_Path_ProgInfo As String
- strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
- SReg_Get_Program_TotalTimesRun = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Total Times Run")
- Exit Function
- err_SReg_Get_Program_TotalTimesRun: 'error handler
- SReg_Get_Program_TotalTimesRun = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_Program_TotalTimesRun & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_Program_TotalTimesRun" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Get_StringValue
- ' Type: Public
- ' By: JA
- ' Desc: Returns a string value from the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strSectionValue registry section value
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim strRetVal As String
- ' strRetVal = SReg_Get_StringValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "Tray ToolTipText", "", True, True)
- ' -OR-
- ' strRetVal = SReg_Get_StringValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "Tray ToolTipText")
- Public Function SReg_Get_StringValue(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strSectionValue As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Get_StringValue 'initiate error handler
- SReg_Get_StringValue = vbNullString 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strSectionValue = Trim(strSectionValue)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .ValueKey = strSectionValue
- .ValueType = REG_SZ
- SReg_Get_StringValue = .Value
- End With
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Get_StringValue: 'error handler
- SReg_Get_StringValue = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Get_StringValue & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Get_StringValue" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_BinaryValue
- ' Type: Public
- ' By: JA
- ' Desc: Saves a binary value to the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strSectionValue registry section value
- ' SReg_bytArr() Array containing the byte(s) to add
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_BinaryValue(HKEY_CURRENT_USER, "Software\My Company\My App", "Color Settings", SReg_bytArr, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_BinaryValue(HKEY_CURRENT_USER, "Software\My Company\My App", "Color Settings", SReg_bytArr)
- Public Function SReg_Set_BinaryValue(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strSectionValue As String, _
- ByRef SReg_bytArr() As Byte, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_BinaryValue 'initiate error handler
- SReg_Set_BinaryValue = 0 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strSectionValue = Trim(strSectionValue)
- With cRegistry
- .ClassKey = HKEY_CURRENT_USER
- .SectionKey = strSectionKey
- .ValueKey = strSectionValue
- .ValueType = REG_BINARY
- .Value = SReg_bytArr()
- End With
- SReg_Set_BinaryValue = 1
- Exit Function
- err_SReg_Set_BinaryValue: 'error handler
- SReg_Set_BinaryValue = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_BinaryValue & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_BinaryValue" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_ComboBoxContents
- ' Type: Public
- ' By: JA
- ' Desc: Saves the contents of a ComboBox to the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to set value
- ' cboCombobox As ComboBox The ComboBox to reference
- ' lngMaxItems As Long Optional Value: Default is -1 (No Limit). Zero or higher will limit the list
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo, -1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo)
- Public Function SReg_Set_ComboBoxContents(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- cboComboBox As ComboBox, _
- Optional lngMaxItems As Long = -1, _
- Optional strErr_MsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_ComboBoxContents 'initiate error handler
- SReg_Set_ComboBoxContents = 0 'set default return
- Dim strValueKey As String
- Dim lngIndex As Long
- Dim strContents As String
- If lngMaxItems = 0 Then
- SReg_Set_ComboBoxContents = 1
- Exit Function
- End If
- strContents = cboComboBox.ListCount
- SReg_Set_StringValue enmClassKey, strSectionKey, "MaxItems", strContents
- If lngMaxItems = -1 Then lngMaxItems = cboComboBox.ListCount
- 'lngIndex = cboCombobox.ListCount
- 'Do Until lngIndex = 0
- For lngIndex = 1 To cboComboBox.ListCount
- If lngIndex <= lngMaxItems Then
- cboComboBox.ListIndex = lngIndex - 1
- strContents = cboComboBox.Text
- strValueKey = lngIndex
- SReg_Set_StringValue enmClassKey, strSectionKey, strValueKey, strContents
- Else
- Exit For
- End If
- Next lngIndex
- ' lngIndex = lngIndex - 1
- 'Loop
- SReg_Set_ComboBoxContents = 1
- Exit Function
- err_SReg_Set_ComboBoxContents: 'error handler
- SReg_Set_ComboBoxContents = -1 'set internal error return
- Debug.Print Now & " | Function: & SReg_Set_ComboBoxContents & | Error: #" & Err.Number & vbTab & Err.Description 'send message to immediate window
- If blnErr_ShowCritical = True Then 'if we want to show critical messages to the user
- Select Case MsgBox("Error: #" & Err.Number & vbTab & Err.Description & vbTab & _
- vbCrLf & vbCrLf & Now & _
- vbCrLf & vbCrLf & "(Use Ctrl+C to copy this message.)", _
- vbAbortRetryIgnore + vbCritical, _
- strErr_MsgBoxTitle & " [Function: SReg_Set_ComboBoxContents - " & Err.Source & "]")
- Case vbAbort: Exit Function
- Case vbRetry: Resume
- Case vbIgnore: Resume Next
- End Select
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_List
- ' Type: Public
- ' By: JA
- ' Desc: Saves a list from a ComboBox or a ListBox
- ' Inputs: enmClassKey selected registry key
- ' ctlControl ComboBox or ListBox
- ' blnSaveLastPos Optional Value: if 'True' then will save last selected item
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_List(HKEY_CURRENT_USER, lstListBox, True, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_List(HKEY_CURRENT_USER, lstListBox, True)
- Public Function SReg_Set_List(enmClassKey As ERegistryClassConstants, _
- ctlControl As Object, _
- Optional blnSaveLastPos As Boolean, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_List 'initiate error handler
- SReg_Set_List = 0 'set default return
- Dim lngListIndex As Long
- Dim strListIndex As String
- Dim strS_Reg_Path_Lists As String
- strS_Reg_Path_Lists = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Lists\" & ctlControl.Name
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_Lists, "Max Items", ctlControl.ListCount
- If blnSaveLastPos = True Then SReg_Set_StringValue enmClassKey, strS_Reg_Path_Lists, "Curr Item", ctlControl.ListIndex
- Select Case TypeName(ctlControl)
- Case "ComboBox", "ListBox"
- For lngListIndex = 0 To ctlControl.ListCount - 1
- ctlControl.ListIndex = lngListIndex
- strListIndex = lngListIndex
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_Lists, strListIndex, ctlControl.Text
- Next lngListIndex
- End Select
- SReg_Set_List = 1
- Exit Function
- err_SReg_Set_List: 'error handler
- SReg_Set_List = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_List & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_List" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_Metrics_Form
- ' Type: Public
- ' By: JA
- ' Desc: Stores the metrics of a form an the view options
- ' Inputs: enmClassKey selected registry key
- ' frmForm form that ListView resides on
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_Metrics_Form(HKEY_CURRENT_USER, Form1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_Metrics_Form(HKEY_CURRENT_USER, Form1)
- Public Function SReg_Set_Metrics_Form(enmClassKey As ERegistryClassConstants, _
- frmForm As Form, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_Metrics_Form 'initiate error handler
- SReg_Set_Metrics_Form = 0 'set default return
- Dim cRegistry As New clsRegistry
- Dim lngForm_Left As Long
- Dim lngForm_Top As Long
- Dim lngForm_Width As Long
- Dim lngForm_Height As Long
- Dim strS_Reg_Path_Form As String
- strS_Reg_Path_Form = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name
- lngForm_Left = frmForm.Left
- lngForm_Top = frmForm.Top
- lngForm_Width = frmForm.Width
- lngForm_Height = frmForm.Height
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strS_Reg_Path_Form
- .ValueType = REG_DWORD
- Select Case frmForm.WindowState
- Case vbMaximized
- .ValueKey = "WindowState": .Value = frmForm.WindowState
- Case vbMinimized
- .ValueKey = "WindowState": .Value = frmForm.WindowState
- Case Else
- .ValueKey = "WindowState": .Value = frmForm.WindowState
- .ValueKey = "Left": .Value = lngForm_Left
- .ValueKey = "Top": .Value = lngForm_Top
- .ValueKey = "Width": .Value = lngForm_Width
- .ValueKey = "Height": .Value = lngForm_Height
- End Select
- End With
- SReg_Set_Metrics_Form = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Set_Metrics_Form: 'error handler
- SReg_Set_Metrics_Form = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_Metrics_Form & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_Metrics_Form" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_Metrics_ListView
- ' Type: Public
- ' By: JA
- ' Desc: Stores the metrics and options of a ListView
- ' Inputs: enmClassKey selected registry key
- ' frmForm form that ListView resides on
- ' lvwListView name of ListView
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_Metrics_ListView(HKEY_CURRENT_USER, Form1, ListView1, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_Metrics_ListView(HKEY_CURRENT_USER, Form1, ListView1)
- Public Function SReg_Set_Metrics_ListView(enmClassKey As ERegistryClassConstants, _
- frmForm As Form, _
- lvwListView As ListView, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_Metrics_ListView 'initiate error handler
- SReg_Set_Metrics_ListView = 0 'set default return
- Dim cRegistry As New clsRegistry
- Dim lngColIndex As Long
- Dim strS_Reg_Path_ListView As String
- strS_Reg_Path_ListView = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name & "\" & lvwListView.Name
- With cRegistry
- .ClassKey = enmClassKey
- .ValueType = REG_SZ
- End With
- With lvwListView
- cRegistry.SectionKey = strS_Reg_Path_ListView
- cRegistry.ValueKey = "AllowColumnReorder": cRegistry.Value = .AllowColumnReorder
- cRegistry.ValueKey = "Checkboxes": cRegistry.Value = .Checkboxes
- cRegistry.ValueKey = "FullRowSelect": cRegistry.Value = .FullRowSelect
- cRegistry.ValueKey = "HideSelection": cRegistry.Value = .HideSelection
- cRegistry.ValueKey = "HotTracking": cRegistry.Value = .HotTracking
- cRegistry.ValueKey = "HoverSelection": cRegistry.Value = .HoverSelection
- cRegistry.ValueType = REG_DWORD
- cRegistry.ValueKey = "LabelEdit": cRegistry.Value = .LabelEdit
- cRegistry.ValueType = REG_SZ
- cRegistry.ValueKey = "LabelWrap": cRegistry.Value = .LabelWrap
- cRegistry.ValueKey = "MultiSelect": cRegistry.Value = .MultiSelect
- cRegistry.ValueKey = "Sorted": cRegistry.Value = .Sorted
- cRegistry.ValueType = REG_DWORD
- cRegistry.ValueKey = "SortKey": cRegistry.Value = .SortKey
- cRegistry.ValueKey = "SortOrder": cRegistry.Value = .SortOrder
- cRegistry.ValueKey = "View": cRegistry.Value = .View
- End With
- If lvwListView.ColumnHeaders.Count < 1 Then Exit Function
- With lvwListView.ColumnHeaders
- For lngColIndex = 1 To lvwListView.ColumnHeaders.Count
- cRegistry.SectionKey = strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text
- cRegistry.ValueType = REG_DWORD
- cRegistry.ValueKey = "Alignment": cRegistry.Value = .Item(lngColIndex).Alignment
- cRegistry.ValueKey = "Position": cRegistry.Value = .Item(lngColIndex).Position
- cRegistry.ValueType = REG_SZ
- cRegistry.ValueKey = "Width": cRegistry.Value = .Item(lngColIndex).Width
- Next lngColIndex
- End With
- SReg_Set_Metrics_ListView = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Set_Metrics_ListView: 'error handler
- SReg_Set_Metrics_ListView = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_Metrics_ListView & | " & frmForm.Name & "." & lvwListView.Name & " Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_Metrics_ListView" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_NumericValue
- ' Type: Public
- ' By: JA
- ' Desc: Adds a numeric value to the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strValueKey registry key to add value to
- ' lngSectionValue value to add
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company", "Copyright", 2001, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company", "Copyright", 2001)
- Public Function SReg_Set_NumericValue(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strValueKey As String, _
- lngSectionValue As Long, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_NumericValue 'initiate error handler
- SReg_Set_NumericValue = 0 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then _
- strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then _
- strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strValueKey = Trim(strValueKey)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .ValueType = REG_DWORD
- .ValueKey = strValueKey
- .Value = lngSectionValue
- End With
- SReg_Set_NumericValue = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Set_NumericValue: 'error handler
- SReg_Set_NumericValue = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_NumericValue & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_NumericValue" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_ODBCData
- ' Type: Public
- ' By: JA
- ' Desc: Creates/Updates an ODBC Connection
- ' Inputs: typSReg_ODBCData SReg_ODBCData object
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Returns
- ' 1 Successful Create or Update
- ' 0 Nothing to do
- ' -1 Internal Function Error
- ' -2 Connection Name Not Specified
- ' -3 Database Not Specified
- ' -4 Driver Not Specified
- ' -5 Server Not Specified
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_ODBCData(typODBCData, True, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_ODBCData(typODBCData, True)
- Public Function SReg_Set_ODBCData(ByRef typODBCData As SReg_ODBCData, _
- Optional blnAutoResetObject As Boolean, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_ODBCData 'initiate error handler
- SReg_Set_ODBCData = 0 'set default return
- Dim enmLocalClassKey As ERegistryClassConstants
- Dim strTrustedConnection As String
- Dim strServerType As String
- Dim strRegRetVal As String
- Dim strODBCINI As String
- strODBCINI = "SOFTWARE\ODBC\ODBC.INI\"
- With typODBCData
- 'clean data_______________________________________________________________________________________________
- .strConnectionName = Trim(.strConnectionName)
- .strDatabase = Trim(.strDatabase)
- .strDescription = Trim(.strDescription)
- .strDriver = Trim(.strDriver)
- .strLastUser = UCase(Trim(.strLastUser))
- .strServer = UCase(Trim(.strServer))
- 'resolve keys_____________________________________________________________________________________________
- Select Case typODBCData.blnLocal
- Case True: enmLocalClassKey = HKEY_CURRENT_USER
- Case False: enmLocalClassKey = HKEY_LOCAL_MACHINE
- End Select
- Select Case typODBCData.enmSReg_ODBC_ServerType
- Case sReg_ST_CRDB2: strServerType = "CR DB2"
- Case sReg_ST_CRInformix: strServerType = "CR Informix"
- Case sReg_ST_CROracle7: strServerType = "CR Oracle7"
- Case sReg_ST_CRSQLBase: strServerType = "CR SQLBase"
- Case sReg_ST_CRSybaseSystem10: strServerType = "CR Sybase System 10"
- Case sReg_ST_FoxProVFP_DBF: strServerType = "Microsoft FoxPro VFP Driver (*.DBF)"
- Case sReg_ST_MSAccess_MDB: strServerType = "Microsoft Access Driver (*.MDB)"
- Case sReg_ST_MSdBase_DBF: strServerType = "Microsoft dBase Driver (*.DBF)"
- Case sReg_ST_MSdBaseVFP_DBF: strServerType = "Microsoft dBase VFP Driver (*.DBF)"
- Case sReg_ST_MSExcel_XLS: strServerType = "Microsoft Excel Driver (*.XLS)"
- Case sReg_ST_MSFoxPro_DBF: strServerType = "Microsoft FoxPro Driver (*.DBF)"
- Case sReg_ST_MSODBCforOracle: strServerType = "Microsoft ODBC for Oracle"
- Case sReg_ST_MSParadox_DB: strServerType = "Microsoft Paradox Driver (*.DB )"
- Case sReg_ST_MSText_TXT_CSV: strServerType = "Microsoft Text Driver (*.TXT; *.CSV)"
- Case sReg_ST_MSVisualFoxPro_DBF: strServerType = "Microsoft Visual FoxPro Driver (*.DBF)"
- Case sReg_ST_MSVisualFoxPro_General: strServerType = "Microsoft Visual FoxPro Driver "
- Case sReg_ST_SQLServer: strServerType = "SQL Server"
- Case Else: strServerType = "Not Supported"
- End Select
- Select Case typODBCData.blnTrustedConnection
- Case True: strTrustedConnection = "Yes"
- Case Else: strTrustedConnection = "No"
- End Select
- 'validate data____________________________________________________________________________________________
- If Len(.strConnectionName) = 0 Then
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Connection Name Not Specified"
- 'if we want to show friendly messages to the user
- If blnErr_ShowFriendly Then
- MsgBox "Error: " & "Connection Name Not Specified" & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbInformation, _
- strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
- End If
- SReg_Set_ODBCData = -2
- Exit Function
- End If
- If Len(.strDatabase) = 0 Then
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Database Not Specified"
- 'if we want to show friendly messages to the user
- If blnErr_ShowFriendly Then
- MsgBox "Error: " & "Database not Specified" & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbInformation, _
- strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
- End If
- SReg_Set_ODBCData = -3
- Exit Function
- End If
- If Len(.strDriver) = 0 Then
- 'if the driver is not given then attempt to look it up
- strRegRetVal = Trim(SReg_Get_StringValue(enmLocalClassKey, _
- "SOFTWARE\ODBC\ODBCINST.INI\" & strServerType, _
- "Driver"))
- If Len(strRegRetVal) = 0 Then
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Driver not Specified"
- 'if we want to show friendly messages to the user
- If blnErr_ShowFriendly Then
- MsgBox "Error: " & "Driver not Specified" & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbInformation, _
- strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
- End If
- SReg_Set_ODBCData = -4
- Exit Function
- Else
- .strDriver = strRegRetVal
- End If
- End If
- If Len(.strServer) = 0 Then
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Server Not Specified"
- 'if we want to show friendly messages to the user
- If blnErr_ShowFriendly Then
- MsgBox "Error: " & "Server Not Specified" & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbInformation, _
- strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
- End If
- SReg_Set_ODBCData = -5
- Exit Function
- End If
- 'set data_________________________________________________________________________________________________
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & "ODBC Data Sources", .strConnectionName, strServerType
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Database", .strDatabase
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Description", .strDescription
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Driver", .strDriver
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "LastUser", .strLastUser
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Server", .strServer
- SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Trusted_Connection", strTrustedConnection
- 'clear object_____________________________________________________________________________________________
- If blnAutoResetObject Then
- .blnLocal = False
- .blnTrustedConnection = False
- .enmSReg_ODBC_ServerType = 0
- .strConnectionName = ""
- .strDatabase = ""
- .strDescription = ""
- .strDriver = ""
- .strLastUser = ""
- .strServer = ""
- End If
- End With
- SReg_Set_ODBCData = 1
- Exit Function
- err_SReg_Set_ODBCData: 'error handler
- SReg_Set_ODBCData = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_ODBCData & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_Program_Info
- ' Type: Public
- ' By: JA
- ' Desc: Stores various Information about a program
- ' Inputs: enmClassKey selected registry key
- ' blnUnloading Optional Value: if 'True' then will set unload information
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Information not added
- ' 1 Information added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As String
- ' lngRetVal = SReg_Set_Program_Info(HKEY_LOCAL_MACHINE, False, "", True, True)
- ' -OR-
- ' lngRetVal = SReg_Set_Program_Info(HKEY_LOCAL_MACHINE, False)
- Public Function SReg_Set_Program_Info(enmClassKey As ERegistryClassConstants, _
- Optional blnUnloading As Boolean, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_Program_Info 'initiate error handler
- SReg_Set_Program_Info = 0 'set default return
- Dim strRegRetVal As String
- Dim strTotalRun As String
- Dim strS_Reg_Path_ProgInfo As String
- strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Comments", App.Comments
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Company Name", App.CompanyName
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "EXE Name", App.EXEName
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "File Description", App.FileDescription
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Help File", App.HelpFile
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "hInstance", App.hInstance
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Legal Copyright", App.LegalCopyright
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Legal Trademarks", App.LegalTrademarks
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Major", App.Major
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Minor", App.Minor
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Path", App.Path
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Product Name", App.ProductName
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Revision", App.Revision
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Thread Id", App.ThreadID
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Title", App.Title
- If blnUnloading = True Then
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Last Closed", Now
- strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Total Times Run")
- If IsNumeric(strRegRetVal) = True Then strTotalRun = strRegRetVal - -1 Else strTotalRun = 1
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Total Times Run", strTotalRun
- Else
- SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Last Run", Now
- End If
- SReg_Set_Program_Info = 1
- Exit Function
- err_SReg_Set_Program_Info: 'error handler
- SReg_Set_Program_Info = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_Program_Info & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_Program_Info" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Set_StringValue
- ' Type: Public
- ' By: JA
- ' Desc: Adds a string to the registry
- ' Inputs: enmClassKey selected registry key
- ' strSectionKey registry path to find value
- ' strValueKey registry key to add value to
- ' strSectionValue registry section value (to add)
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 string not added
- ' 1 string added successfully
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Set_StringValue(HKEY_LOCAL_MACHINE, "Software\Microfot\Windows\CurrentVersion", "Run", "MyStartupApp.exe", "", True, True)
- Public Function SReg_Set_StringValue(enmClassKey As ERegistryClassConstants, _
- strSectionKey As String, _
- strValueKey As String, _
- strSectionValue As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Set_StringValue 'initiate error handler
- SReg_Set_StringValue = 0 'set default return
- Dim cRegistry As New clsRegistry
- If Left(strSectionKey, 1) = "\" Then strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
- If Right(strSectionKey, 1) = "\" Then strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
- strValueKey = Trim(strValueKey)
- strSectionValue = Trim(strSectionValue)
- With cRegistry
- .ClassKey = enmClassKey
- .SectionKey = strSectionKey
- .ValueType = REG_SZ
- .ValueKey = strValueKey
- .Value = strSectionValue
- End With
- SReg_Set_StringValue = 1
- Set cRegistry = Nothing
- Exit Function
- err_SReg_Set_StringValue: 'error handler
- SReg_Set_StringValue = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Set_StringValue & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Set_StringValue" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Xtr_AssociateFileType
- ' Type: Public
- ' By: JA
- ' Desc: Associates a program with a file type
- ' Inputs: strExePath Path to the executable (including executable)
- ' strClassName Class name of the exe
- ' strClassDesc Description of the exe's class type
- ' strFileExtension the extension to associate the program with
- ' strOpenMenuText Optional Value: default is "&Open...": Menu text for open
- ' blnSupportPrinting Optional Value: default is False: Do you want to have an 'Print' option in the menu?
- ' strPrintMenuText Optional Value: default is "&Print...": Menu text for printing
- ' blnSupportNew Optional Value: default is False: Do you want to have an 'New' option in the menu?
- ' strNewMenuText Optional Value: default is "&New...": Menu text for making a new (empty) file
- ' blnSupportInstall Optional Value: default is False: Do you want to have an 'Install' option in the menu?
- ' strInstallMenuText Optional Value: default is "&Install...": Menu text for installing the file
- ' strDefaultIconIndex Optional Value: default is -1: Icon index to use with the file
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Returns:
- ' -1 Internal error occured
- ' 0 Association not made
- ' 1 Association made
- ' Note: None
- ' Example:
- ' Dim lngRetVal As Long
- ' lngRetVal = SReg_Xtr_AssociateFileType("C:\Windows\Notepad.exe", "text/plain", "Text Document", ".txt", "&Open with Notepad...", True, "Send to &Printer...", True, "Create &New Text File...", False, , , "", True, True)
- Public Function SReg_Xtr_AssociateFileType(strExePath As String, _
- strClassName As String, _
- strClassDesc As String, _
- strFileExtension As String, _
- Optional strOpenMenuText As String = "&Open...", _
- Optional blnSupportPrinting As Boolean = False, _
- Optional strPrintMenuText As String = "&Print...", _
- Optional blnSupportNew As Boolean = False, _
- Optional strNewMenuText As String = "&New...", _
- Optional blnSupportInstall As Boolean = False, _
- Optional strInstallMenuText As String = "&Install...", _
- Optional strDefaultIconIndex As String = -1, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As Long
- On Error GoTo err_SReg_Xtr_AssociateFileType 'initiate error handler
- SReg_Xtr_AssociateFileType = 0 'set default return
- Dim cRegistry As New clsRegistry
- With cRegistry
- .CreateEXEAssociation strExePath, _
- strClassName, _
- strClassDesc, _
- strFileExtension, _
- strOpenMenuText, _
- blnSupportPrinting, _
- strPrintMenuText, _
- blnSupportNew, _
- strNewMenuText, _
- blnSupportInstall, _
- strInstallMenuText, _
- strDefaultIconIndex
- End With
- SReg_Xtr_AssociateFileType = 1
- Exit Function
- err_SReg_Xtr_AssociateFileType: 'error handler
- SReg_Xtr_AssociateFileType = -1 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Xtr_AssociateFileType & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Xtr_AssociateFileType" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Xtr_GetDefaultApp
- ' Type: Public
- ' By: JA
- ' Desc: Returns the defualt application to launch a specified file
- ' Inputs: strFileName file name (can include path) to find default program for
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim strRetVal As String
- ' strRetVal = SReg_Xtr_GetDefaultApp("C:\Windows\ReadMe.txt", "", True, True)
- ' -OR-
- ' strRetVal = SReg_Xtr_GetDefaultApp("C:\Windows\ReadMe.txt")
- ' strRetVal will now contain: "C:\WINNT\system32\NOTEPAD.EXE %1
- Public Function SReg_Xtr_GetDefaultApp(strFileName As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Xtr_GetDefaultApp 'initiate error handler
- SReg_Xtr_GetDefaultApp = vbNullString 'set default return
- Dim strFileExt As String
- Dim strFileType As String
- Dim strCurrChar As String
- Dim intCharPos As String
- Dim strTypeName As String
- Dim strDefAction As String
- intCharPos = Len(strFileName)
- Do Until strCurrChar = "."
- strCurrChar = Mid(strFileName, intCharPos, 1)
- strFileExt = strCurrChar & strFileExt
- If strCurrChar = "." Then Exit Do
- intCharPos = intCharPos - 1
- Loop
- strTypeName = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strFileExt, "")
- strFileType = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName, "")
- strDefAction = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName & "\shell", "")
- SReg_Xtr_GetDefaultApp = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName & "\shell\" & strDefAction & "\command", "")
- SReg_Xtr_GetDefaultApp = Trim(SReg_Xtr_GetDefaultApp)
- If Len(Trim(SReg_Xtr_GetDefaultApp)) < 1 Then
- SReg_Xtr_GetDefaultApp = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName & "\shell\open\command", "")
- If Len(Trim(SReg_Xtr_GetDefaultApp)) < 1 Then SReg_Xtr_GetDefaultApp = "Unknown"
- End If
- Exit Function
- err_SReg_Xtr_GetDefaultApp: 'error handler
- SReg_Xtr_GetDefaultApp = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Xtr_GetDefaultApp & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Xtr_GetDefaultApp" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- ' Module: modRegistry.bas
- ' Function: SReg_Xtr_GetFileType
- ' Type: Public
- ' By: JA
- ' Desc: Descriptive File Type
- ' Inputs: strFileName file name (can include path) to find file type name from
- ' strMsgBoxTitle Optional Value: Caption of the error message box's
- ' blnErr_ShowFriendly Optional Value: if 'True' then will display friendly errors
- ' blnErr_ShowCritical Optional Value: if 'True' then will display critical errors
- ' Note: None
- ' Example:
- ' Dim strRetVal As String
- ' strRetVal = SReg_Xtr_GetFileType("C:\Windows\ReadMe.txt", "", True, True)
- ' -OR-
- ' strRetVal = SReg_Xtr_GetFileType("C:\Windows\ReadMe.txt")
- ' strRetVal will now contain: "Text Document"
- Public Function SReg_Xtr_GetFileType(strFileName As String, _
- Optional strMsgBoxTitle As String, _
- Optional blnErr_ShowFriendly As Boolean, _
- Optional blnErr_ShowCritical As Boolean _
- ) As String
- On Error GoTo err_SReg_Xtr_GetFileType 'initiate error handler
- SReg_Xtr_GetFileType = vbNullString 'set default return
- Dim strFileExt As String
- Dim strFileType As String
- Dim strCurrChar As String
- Dim intCharPos As String
- Dim strTypeName As String
- intCharPos = Len(strFileName)
- Do Until strCurrChar = "."
- strCurrChar = Mid(strFileName, intCharPos, 1)
- strFileExt = strCurrChar & strFileExt
- If strCurrChar = "." Then Exit Do
- intCharPos = intCharPos - 1
- Loop
- strTypeName = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strFileExt, "")
- SReg_Xtr_GetFileType = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName, "")
- If Len(Trim(SReg_Xtr_GetFileType)) < 1 Then SReg_Xtr_GetFileType = "Unknown"
- Exit Function
- err_SReg_Xtr_GetFileType: 'error handler
- SReg_Xtr_GetFileType = vbNullString 'set internal error return
- 'send message to immediate window
- Debug.Print Now & " | Function: & SReg_Xtr_GetFileType & | Error: #" & _
- Err.Number & vbTab & Err.Description
- 'if we want to show critical messages to the user
- If blnErr_ShowCritical = True Then
- 'notify the user
- MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
- vbCrLf & vbCrLf & Now, _
- vbOKOnly + vbCritical, _
- strMsgBoxTitle & " [Function: SReg_Xtr_GetFileType" & "]"
- End If
- Err.Clear 'clear the error object
- On Error Resume Next
- 'Cleanup
- End Function
- '__________________________________________________________
- 'To Get All The SubKeys of a Key
- 'Getting all the values with a key is achieved in a similar way,
- 'except you use EnumerateValues instead of EnumerateSections
- '
- ' Dim c As New clsRegistry
- ' Dim sKeys() As String, iKeyCount As Long
- '
- ' With c
- ' .ClassKey = HKEY_LOCAL_MACHINE
- ' .SectionKey = "Software"
- ' .EnumerateSections(sKeys(), iKeyCount)
- ' For iKey = 1 To iKeyCount
- ' Debug.Print sKeys(iKey)
- ' Next iKey
- ' End With
- '
- '__________________________________________________________
- 'To Read BINARY values from the registry
- 'Binary values are returned as a variant of type byte array.
- 'This code demonstrates how to format the returned value into
- 'a string of hexadecimal values, similar to the display
- 'provided in RegEdit:
- '
- ' Dim cR As New clsRegistry
- ' Dim iByte As Long
- ' Dim vR As Variant
- '
- ' With cR
- ' .ClassKey = HKEY_CURRENT_USER
- ' .SectionKey = "Control Panel\Appearance"
- ' .ValueKey = "CustomColors"
- ' vR = .Value
- '
- ' If .ValueType = REG_BINARY Then
- ' ' Read through the byte array and output it as a series of hex values:
- ' For iByte = LBound(vR) To UBound(vR)
- ' sOut = sOut & "&H"
- ' If (iByte < &H10) Then
- ' sOut = sOut & "0"
- ' End If
- ' sOut = sOut & Hex$(vR(iByte)) & " "
- ' Next iByte
- ' Else
- ' sOut = vR
- ' End If
- '
- ' Debug.Print sOut
- ' End With
- '
- '__________________________________________________________
- 'To Set BINARY values to the registry
- 'Similarly, to store binary values in the registry, clsRegistry.cls
- 'expects a byte array of the binary values you wish to store.
- 'This example (rather uselessly!) stores all the Red, Green,
- 'Blue values of each of VB's QBColors into a binary array:
- '
- ' Dim cR As New clsRegistry
- ' Dim i As Long
- ' Dim lC As Long
- ' Dim bR As Byte
- ' Dim bG As Byte
- ' Dim bB As Byte
- ' Dim bOut() As Byte
- '
- ' ' Create a binary array containing all the Red,Green,Blue values of the QBColors:
- ' ReDim bOut(0 To 15 * 3 - 1) As Byte
- ' For i = 1 To 15
- ' ' Get the Red, Green, Blue for the QBColor at index i:
- ' lC = QBColor(i)
- ' bR = (lC And &HFF&)
- ' bG = ((lC And &HFF00&) \ &H100&)
- ' bB = ((lC And &HFF0000) \ &H10000)
- '
- ' ' Add Red, Green, Blue to the byte array to store:
- ' bOut((i - 1) * 3) = bR
- ' bOut((i - 1) * 3 + 1) = bG
- ' bOut((i - 1) * 3 + 2) = bB
- ' Next i
- '
- ' ' Store it:
- ' With cR
- ' .ClassKey = HKEY_CURRENT_USER
- ' .SectionKey = "software\Company Name\Test\clsRegistry\Binary Test"
- ' .ValueKey = "QBColors"
- ' .ValueType = REG_BINARY
- ' .Value = bOut()
- ' End With
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement