Advertisement
PikaNikz

modRegistry.bas

Feb 10th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Attribute VB_Name = "modRegistry"
  2. Option Explicit
  3.  
  4. '_______________________________________________________________
  5. ' Module:           modRegistry
  6. ' Author:           JA
  7. ' Purpose:          Wrapper for Class: clsRegistry
  8. ' Functions:        See Comments above each function for details
  9. '    SReg_Del_Key                    Deletes a given registry key
  10. '    SReg_Del_Metrics_Form           Deletes the metrics and view options of a form
  11. '    SReg_Del_Metrics_ListView       Deletes the metrics and options for a ListView
  12. '    SReg_Del_ODBCData               Deletes an ODBC Connection
  13. '    SReg_Del_Value                  Deletes a given registry value
  14. '    SReg_Enm_Sections               Enumerates sections of the registry from the given key
  15. '    SReg_Enm_Values                 Enumerates values from a given key
  16. '    SReg_Get_BinaryValue            Obtains a binary value from the registry
  17. '    SReg_Get_ComboBoxContents       Retrieves the contents of a ComboBox from the registry
  18. '    SReg_Get_List                   Retrieves the list items of a ComboBox or ListBox
  19. '    SReg_Get_Metrics_Form           Retrieves the metrics and view options of a form
  20. '    SReg_Get_Metrics_ListView       Retrieves the metrics and options for a ListView
  21. '    SReg_Get_NumericValue           Returns a numeric value from the registry
  22. '    SReg_Get_ODBCData               Returns a filled SReg_ODBCData object with the corresponding data from the connection
  23. '    SReg_Get_Program_CompanyName    Returns the Company Name from the project (or exe) properties
  24. '    SReg_Get_Program_Last_Close     Returns the last date and time that the program was closed
  25. '    SReg_Get_Program_Last_Run       Returns the last date and time that the program was run
  26. '    SReg_Get_Program_LastVersion    Returns the application version from the registry
  27. '    SReg_Get_Program_TotalTimesRun  Returns the number of times a program has been run
  28. '    SReg_Get_StringValue            Returns a string value from the registry
  29. '    SReg_Set_BinaryValue            Saves a binary value to the registry
  30. '    SReg_Set_ComboBoxContents       Saves the contents of a ComboBox to the registry
  31. '    SReg_Set_List                   Saves a list from a ComboBox or a ListBox
  32. '    SReg_Set_Metrics_Form           Stores the metrics of a form an the view options
  33. '    SReg_Set_Metrics_ListView       Stores the metrics and options of a ListView
  34. '    SReg_Set_NumericValue           Adds a numeric value to the registry
  35. '    SReg_Set_ODBCData               Creates/Updates an ODBC Connection
  36. '    SReg_Set_Program_Info           Stores various Information about a program
  37. '    SReg_Set_StringValue            Adds a string to the registry
  38. '    SReg_Xtr_AssociateFileType      Associates a program with a file type
  39. '    SReg_Xtr_GetDefaultApp          Returns the defualt application to launch a specified file
  40. '    SReg_Xtr_GetFileType            Descriptive File Type
  41. ' Comments:         Requires clsRegistry
  42. '_______________________________________________________________
  43. Public Type SReg_RetVal
  44.     strKeyName                      As String
  45.     varKeyValue                     As Variant
  46. End Type
  47.  
  48. Public SReg_Values_Arr()            As SReg_RetVal
  49. Public SReg_Sections_Arr()          As Variant
  50. Public SReg_bytArr()                As Byte
  51.  
  52. Public Enum SReg_ODBC_ServerType
  53.     sReg_ST_CRDB2 = 0
  54.     sReg_ST_CRInformix = 1
  55.     sReg_ST_CROracle7 = 2
  56.     sReg_ST_CRSQLBase = 3
  57.     sReg_ST_CRSybaseSystem10 = 4
  58.     sReg_ST_FoxProVFP_DBF = 5
  59.     sReg_ST_MSAccess_MDB = 6
  60.     sReg_ST_MSdBase_DBF = 7
  61.     sReg_ST_MSdBaseVFP_DBF = 8
  62.     sReg_ST_MSExcel_XLS = 9
  63.     sReg_ST_MSFoxPro_DBF = 10
  64.     sReg_ST_MSODBCforOracle = 11
  65.     sReg_ST_MSParadox_DB = 12
  66.     sReg_ST_MSText_TXT_CSV = 13
  67.     sReg_ST_MSVisualFoxPro_DBF = 14
  68.     sReg_ST_MSVisualFoxPro_General = 15
  69.     sReg_ST_SQLServer = 16
  70. End Enum
  71.  
  72. Public Type SReg_ODBCData
  73.     blnLocal                        As Boolean
  74.     blnTrustedConnection            As Boolean
  75.     enmSReg_ODBC_ServerType         As SReg_ODBC_ServerType
  76.     strConnectionName               As String
  77.     strDatabase                     As String
  78.     strDriver                       As String
  79.     strDescription                  As String
  80.     strLastUser                     As String
  81.     strServer                       As String
  82. End Type
  83. '
  84.  
  85. ' Module:       modRegistry.bas
  86. ' Function:     SReg_Del_Key
  87. ' Type:         Public
  88. ' By:           JA
  89. ' Desc:         Deletes a given registry key
  90. ' Inputs:       enmClassKey             selected registry key
  91. '               strSectionKey           registry path to delete
  92. '               strMsgBoxTitle          Optional Value: Title to use in error MsgBox's
  93. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  94. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  95. ' Returns:
  96. '               -1      Internal error occured
  97. '                0      Key not deleted
  98. '                1      Key deleted successfully
  99. ' Note:         !! Warning : You probably don't want to run the example !!
  100. ' Example:
  101. '   Dim lngRetVal As Long
  102. '   lngRetVal = SReg_Del_Key(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "", True, True)
  103. '   -OR-
  104. '   lngRetVal = SReg_Del_Key(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce")
  105. Public Function SReg_Del_Key(enmClassKey As ERegistryClassConstants, _
  106.                              strSectionKey As String, _
  107.                              Optional strMsgBoxTitle As String, _
  108.                              Optional blnErr_ShowFriendly As Boolean, _
  109.                              Optional blnErr_ShowCritical As Boolean _
  110.                             ) As Long
  111. On Error GoTo err_SReg_Del_Key    'initiate error handler
  112.    SReg_Del_Key = 0    'set default return
  113.    
  114.     Dim cRegistry       As New clsRegistry
  115.    
  116.     If Left(strSectionKey, 1) = "\" Then _
  117.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  118.    
  119.     If Right(strSectionKey, 1) = "\" Then _
  120.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  121.    
  122.     With cRegistry
  123.         .ClassKey = enmClassKey
  124.         .SectionKey = strSectionKey
  125.         .DeleteKey
  126.     End With
  127.    
  128.     SReg_Del_Key = 1
  129.     Set cRegistry = Nothing
  130.     Exit Function
  131. err_SReg_Del_Key:    'error handler
  132.    SReg_Del_Key = -1    'set internal error return
  133.    'send message to immediate window
  134.    Debug.Print Now & " | Function: & SReg_Del_Key & | Error: #" & _
  135.                 Err.Number & vbTab & Err.Description
  136.     'if we want to show critical messages to the user
  137.    If blnErr_ShowCritical = True Then
  138.         'notify the user
  139.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  140.                vbCrLf & vbCrLf & Now, _
  141.                vbOKOnly + vbCritical, _
  142.                strMsgBoxTitle & " [Function: SReg_Del_Key" & "]"
  143.     End If
  144.     Err.Clear    'clear the error object
  145. On Error Resume Next
  146.     'Cleanup
  147.    
  148. End Function
  149.  
  150. ' Module:       modRegistry.bas
  151. ' Function:     SReg_Del_Metrics_Form
  152. ' Type:         Public
  153. ' By:           JA
  154. ' Desc:         Deletes the metrics and view options of a form
  155. ' Inputs:       enmClassKey             selected registry key
  156. '               frmForm                 form to delete values for
  157. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  158. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  159. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  160. ' Returns:
  161. '               -1      Internal error occured
  162. '                0      Information not deleted
  163. '                1      Information deleted successfully
  164. ' Note:         None
  165. ' Example:
  166. '   Dim lngRetVal As Long
  167. '   lngRetVal = SReg_Del_Metrics_Form(HKEY_LOCAL_MACHINE, Form1, "", True, True)
  168. '   -OR-
  169. '   lngRetVal = SReg_Del_Metrics_Form(HKEY_LOCAL_MACHINE, Form1)
  170. Public Function SReg_Del_Metrics_Form(enmClassKey As ERegistryClassConstants, _
  171.                                       frmForm As Form, _
  172.                                       Optional strMsgBoxTitle As String, _
  173.                                       Optional blnErr_ShowFriendly As Boolean, _
  174.                                       Optional blnErr_ShowCritical As Boolean _
  175.                                      ) As Long
  176. On Error GoTo err_SReg_Del_Metrics_Form    'initiate error handler
  177.    SReg_Del_Metrics_Form = 0    'set default return
  178.    
  179.     Dim strS_Reg_Path_Form      As String
  180.    
  181.     strS_Reg_Path_Form = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name
  182.    
  183.     SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "WindowState"
  184.     SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Left"
  185.     SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Top"
  186.     SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Width"
  187.     SReg_Del_Value enmClassKey, strS_Reg_Path_Form, "Height"
  188.    
  189.     SReg_Del_Key enmClassKey, strS_Reg_Path_Form
  190.    
  191.     SReg_Del_Metrics_Form = 1
  192.     Exit Function
  193. err_SReg_Del_Metrics_Form:    'error handler
  194.    SReg_Del_Metrics_Form = -1    'set internal error return
  195.    'send message to immediate window
  196.    Debug.Print Now & " | Function: & SReg_Del_Metrics_Form & | Error: #" & _
  197.                 Err.Number & vbTab & Err.Description
  198.     'if we want to show critical messages to the user
  199.    If blnErr_ShowCritical = True Then
  200.         'notify the user
  201.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  202.                vbCrLf & vbCrLf & Now, _
  203.                vbOKOnly + vbCritical, _
  204.                strMsgBoxTitle & " [Function: SReg_Del_Metrics_Form" & "]"
  205.     End If
  206.     Err.Clear    'clear the error object
  207. On Error Resume Next
  208.     'Cleanup
  209.    
  210. End Function
  211.  
  212. ' Module:       modRegistry.bas
  213. ' Function:     SReg_Del_Metrics_ListView
  214. ' Type:         Public
  215. ' By:           JA
  216. ' Desc:         Deletes the metrics and options for a ListView
  217. ' Inputs:       enmClassKey             selected registry key
  218. '               frmForm                 form where ListView resides
  219. '               lvwListView             name of ListView
  220. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  221. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  222. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  223. ' Returns:
  224. '               -1      Internal error occured
  225. '                0      Information not deleted
  226. '                1      Information deleted successfully
  227. ' Note:         None
  228. ' Example:
  229. '   Dim lngRetVal As Long
  230. '   lngRetVal = SReg_Del_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1, "", True, True)
  231. '   -OR-
  232. '   lngRetVal = SReg_Del_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1)
  233. Public Function SReg_Del_Metrics_ListView(enmClassKey As ERegistryClassConstants, _
  234.                                           frmForm As Form, _
  235.                                           lvwListView As ListView, _
  236.                                           Optional strMsgBoxTitle As String, _
  237.                                           Optional blnErr_ShowFriendly As Boolean, _
  238.                                           Optional blnErr_ShowCritical As Boolean _
  239.                                          ) As Long
  240. On Error GoTo err_SReg_Del_Metrics_ListView    'initiate error handler
  241.    SReg_Del_Metrics_ListView = 0    'set default return
  242.    
  243.     Dim lngColIndex                 As Long
  244.     Dim strS_Reg_Path_ListView      As String
  245.    
  246.     strS_Reg_Path_ListView = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name & "\" & lvwListView.Name
  247.    
  248.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "AllowColumnReorder"
  249.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "Checkboxes"
  250.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "FullRowSelect"
  251.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "HideSelection"
  252.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "HotTracking"
  253.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "HoverSelection"
  254.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "LabelEdit"
  255.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "LabelWrap"
  256.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "MultiSelect"
  257.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "Sorted"
  258.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "SortKey"
  259.     SReg_Del_Value enmClassKey, strS_Reg_Path_ListView, "SortOrder"
  260.    
  261.     With lvwListView.ColumnHeaders
  262.         For lngColIndex = 1 To lvwListView.ColumnHeaders.Count
  263.             SReg_Del_Value enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text, "Alignment"
  264.             SReg_Del_Value enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text, "Position"
  265.             SReg_Del_Value enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text, "Width"
  266.         Next lngColIndex
  267.        
  268.         SReg_Del_Key enmClassKey, strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text
  269.         SReg_Del_Key enmClassKey, strS_Reg_Path_ListView
  270.        
  271.     End With
  272.    
  273.     Exit Function
  274. err_SReg_Del_Metrics_ListView:    'error handler
  275.    SReg_Del_Metrics_ListView = -1    'set internal error return
  276.    'send message to immediate window
  277.    Debug.Print Now & " | Function: & SReg_Del_Metrics_ListView & | Error: #" & _
  278.                 Err.Number & vbTab & Err.Description
  279.     'if we want to show critical messages to the user
  280.    If blnErr_ShowCritical = True Then
  281.         'notify the user
  282.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  283.                vbCrLf & vbCrLf & Now, _
  284.                vbOKOnly + vbCritical, _
  285.                strMsgBoxTitle & " [Function: SReg_Del_Metrics_ListView" & "]"
  286.     End If
  287.     Err.Clear    'clear the error object
  288. On Error Resume Next
  289.     'Cleanup
  290.    
  291. End Function
  292.  
  293. ' Module:       modRegistry.bas
  294. ' Function:     SReg_Del_ODBCData
  295. ' Type:         Public
  296. ' By:           JA
  297. ' Desc:         Deletes an ODBC Connection
  298. ' Inputs:       blnLocal                Local Variable: if 'True" then HKEY_LOCAL_MACHINE else HKEY_CURRENT_USER
  299. '               strConnectionName       Name of connection
  300. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  301. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  302. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  303. ' Returns
  304. '    1          Success
  305. '    0          Nothing to do
  306. '   -1          Internal Function Error
  307. ' Note:         None
  308. ' Example:
  309. '   Dim lngRetVal As Long
  310. '   lngRetVal = SReg_Del_ODBCData(True, "MyConnection", "", True, True)
  311. '   -OR-
  312. '   lngRetVal = SReg_Del_ODBCData(True, "MyConnection")
  313. Public Function SReg_Del_ODBCData(blnLocal As Boolean, _
  314.                                   strConnectionName As String, _
  315.                                   Optional strMsgBoxTitle As String, _
  316.                                   Optional blnErr_ShowFriendly As Boolean, _
  317.                                   Optional blnErr_ShowCritical As Boolean _
  318.                                  ) As Long
  319. On Error GoTo err_SReg_Del_ODBCData    'initiate error handler
  320.    SReg_Del_ODBCData = 0    'set default return
  321.    
  322.     Dim enmLocalClassKey            As ERegistryClassConstants
  323.     Dim strODBCINI                  As String
  324.    
  325.     strODBCINI = "SOFTWARE\ODBC\ODBC.INI\"
  326.    
  327.     Select Case blnLocal
  328.         Case True:      enmLocalClassKey = HKEY_CURRENT_USER
  329.         Case False:     enmLocalClassKey = HKEY_LOCAL_MACHINE
  330.     End Select
  331.    
  332.     SReg_Del_Value enmLocalClassKey, strODBCINI & "ODBC Data Sources", strConnectionName
  333.     SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Database"
  334.     SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Description"
  335.     SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Driver"
  336.     SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "LastUser"
  337.     SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Server"
  338.     SReg_Del_Value enmLocalClassKey, strODBCINI & strConnectionName, "Trusted_Connection"
  339.    
  340.     SReg_Del_Key enmLocalClassKey, strODBCINI & strConnectionName
  341.    
  342.     SReg_Del_ODBCData = 1
  343.     Exit Function
  344. err_SReg_Del_ODBCData:    'error handler
  345.    SReg_Del_ODBCData = -1    'set internal error return
  346.    'send message to immediate window
  347.    Debug.Print Now & " | Function: & SReg_Del_ODBCData & | Error: #" & _
  348.                 Err.Number & vbTab & Err.Description
  349.     'if we want to show critical messages to the user
  350.    If blnErr_ShowCritical = True Then
  351.         'notify the user
  352.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  353.                vbCrLf & vbCrLf & Now, _
  354.                vbOKOnly + vbCritical, _
  355.                strMsgBoxTitle & " [Function: SReg_Del_ODBCData" & "]"
  356.     End If
  357.     Err.Clear    'clear the error object
  358. On Error Resume Next
  359.     'Cleanup
  360.    
  361. End Function
  362.  
  363. ' Module:       modRegistry.bas
  364. ' Function:     SReg_Del_Value
  365. ' Type:         Public
  366. ' By:           JA
  367. ' Desc:         Deletes a given registry value
  368. ' Inputs:       enmClassKey             selected registry key
  369. '               strSectionKey           registry path to find value
  370. '               strSectionValue         registry section value (to delete)
  371. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  372. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  373. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  374. ' Returns:
  375. '               -1      Internal error occured
  376. '                0      Value not deleted
  377. '                1      Value deleted successfully
  378. ' Note:         !! Warning : You probably don't want to run the example !!
  379. ' Example:
  380. '   Dim lngRetVal As Long
  381. '   lngRetVal = SReg_Del_Value(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "Finish Install", "", True, True)
  382. '   -OR-
  383. '   lngRetVal = SReg_Del_Value(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "Finish Install")
  384. Public Function SReg_Del_Value(enmClassKey As ERegistryClassConstants, _
  385.                                strSectionKey As String, _
  386.                                strSectionValue As String, _
  387.                                Optional strMsgBoxTitle As String, _
  388.                                Optional blnErr_ShowFriendly As Boolean, _
  389.                                Optional blnErr_ShowCritical As Boolean _
  390.                               ) As Long
  391. On Error GoTo err_SReg_Del_Value    'initiate error handler
  392.    SReg_Del_Value = 0    'set default return
  393.    
  394.     Dim cRegistry       As New clsRegistry
  395.    
  396.     If Left(strSectionKey, 1) = "\" Then _
  397.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  398.    
  399.     If Right(strSectionKey, 1) = "\" Then _
  400.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  401.    
  402.     strSectionValue = Trim(strSectionValue)
  403.    
  404.     With cRegistry
  405.         .ClassKey = enmClassKey
  406.         .SectionKey = strSectionKey
  407.         .SectionKey = strSectionValue
  408.         .DeleteValue
  409.     End With
  410.    
  411.     SReg_Del_Value = 1
  412.     Set cRegistry = Nothing
  413.     Exit Function
  414. err_SReg_Del_Value:    'error handler
  415.    SReg_Del_Value = -1    'set internal error return
  416.    'send message to immediate window
  417.    Debug.Print Now & " | Function: & SReg_Del_Value & | Error: #" & _
  418.                 Err.Number & vbTab & Err.Description
  419.     'if we want to show critical messages to the user
  420.    If blnErr_ShowCritical = True Then
  421.         'notify the user
  422.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  423.                vbCrLf & vbCrLf & Now, _
  424.                vbOKOnly + vbCritical, _
  425.                strMsgBoxTitle & " [Function: SReg_Del_Value" & "]"
  426.     End If
  427.     Err.Clear    'clear the error object
  428. On Error Resume Next
  429.     'Cleanup
  430.    
  431. End Function
  432.  
  433. ' Module:       modRegistry.bas
  434. ' Function:     SReg_Enm_Sections
  435. ' Type:         Public
  436. ' By:           JA
  437. ' Desc:         Enumerates sections of the registry from the given key
  438. ' Inputs:       enmClassKey             selected registry key
  439. '               strSectionKey           registry path to find value(s)
  440. '               SReg_Sections_Arr()     Array to hold returns
  441. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  442. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  443. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  444. ' Returns:
  445. '               -1      Internal error occured
  446. '                0      Information not obtained
  447. '                1      Information obtained successfully
  448. ' Note:         None
  449. ' Example:
  450. '    Dim lngRetVal As Long
  451. '    Dim lngIndex As Long
  452. '    lngRetVal = SReg_Enm_Sections(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion", SReg_Sections_Arr, "", True, True)
  453. '    If lngRetVal > 0 Then
  454. '        For lngIndex = 0 To UBound(SReg_Sections_Arr) - 1
  455. '            List1.AddItem SReg_Sections_Arr(lngIndex)
  456. '        Next lngIndex
  457. '    End If
  458. Public Function SReg_Enm_Sections(enmClassKey As ERegistryClassConstants, _
  459.                                   strSectionKey As String, _
  460.                                   Optional strMsgBoxTitle As String, _
  461.                                   Optional blnErr_ShowFriendly As Boolean, _
  462.                                   Optional blnErr_ShowCritical As Boolean _
  463.                                  ) As Long
  464. On Error GoTo err_SReg_Enm_Sections    'initiate error handler
  465.    SReg_Enm_Sections = 0    'set default return
  466.    
  467.     Dim cRegistry           As New clsRegistry
  468.     Dim strKeys()           As String
  469.     Dim lngKeyCount         As Long
  470.     Dim lngKeyIndex         As Long
  471.    
  472.     ReDim SReg_Sections_Arr(0)
  473.    
  474.     With cRegistry
  475.         .ClassKey = enmClassKey
  476.         .SectionKey = strSectionKey
  477.         .EnumerateSections strKeys(), lngKeyCount
  478.         ReDim SReg_Sections_Arr(lngKeyCount)
  479.         For lngKeyIndex = 1 To lngKeyCount
  480.             SReg_Sections_Arr(lngKeyIndex - 1) = strKeys(lngKeyIndex)
  481.         Next lngKeyIndex
  482.     End With
  483.    
  484.     SReg_Enm_Sections = 1
  485.     Exit Function
  486. err_SReg_Enm_Sections:    'error handler
  487.    SReg_Enm_Sections = -1    'set internal error return
  488.    'send message to immediate window
  489.    Debug.Print Now & " | Function: & SReg_Enm_Sections & | Error: #" & _
  490.                 Err.Number & vbTab & Err.Description
  491.     'if we want to show critical messages to the user
  492.    If blnErr_ShowCritical = True Then
  493.         'notify the user
  494.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  495.                vbCrLf & vbCrLf & Now, _
  496.                vbOKOnly + vbCritical, _
  497.                strMsgBoxTitle & " [Function: SReg_Enm_Sections" & "]"
  498.     End If
  499.     Err.Clear    'clear the error object
  500. On Error Resume Next
  501.     'Cleanup
  502.    
  503. End Function
  504.  
  505. ' Module:       modRegistry.bas
  506. ' Function:     SReg_Enm_Values
  507. ' Type:         Public
  508. ' By:           JA
  509. ' Desc:         Enumerates values from a given key
  510. ' Inputs:       enmClassKey             selected registry key
  511. '               strSectionKey           registry path to find value(s)
  512. '               SReg_Sections_Arr()     Array to hold returns
  513. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  514. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  515. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  516. ' Returns:
  517. '               -1      Internal error occured
  518. '                0      Information not obtained
  519. '                1      Information obtained successfully
  520. ' Note:         None
  521. ' Example:
  522. '    Dim lngRetVal As Long
  523. '    Dim lngIndex As Long
  524. '    lngRetVal = SReg_Enm_Values(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", SReg_Values_Arr, "", True, True)
  525. '    If lngRetVal > 0 Then
  526. '        For lngIndex = 0 To UBound(SReg_Values_Arr) - 1
  527. '            List1.AddItem SReg_Values_Arr(lngIndex).strKeyName & " - " & SReg_Values_Arr(lngIndex).varKeyValue
  528. '        Next lngIndex
  529. '    End If
  530. Public Function SReg_Enm_Values(enmClassKey As ERegistryClassConstants, _
  531.                                 strSectionKey As String, _
  532.                                 ByRef SReg_Values_Arr() As SReg_RetVal, _
  533.                                 Optional strMsgBoxTitle As String, _
  534.                                 Optional blnErr_ShowFriendly As Boolean, _
  535.                                 Optional blnErr_ShowCritical As Boolean _
  536.                                ) As Long
  537. On Error GoTo err_SReg_Enm_Values    'initiate error handler
  538.    SReg_Enm_Values = 0    'set default return
  539.    
  540.     Dim cRegistry           As New clsRegistry
  541.     Dim strValues()         As String
  542.     Dim lngKeyCount         As Long
  543.     Dim lngKeyIndex         As Long
  544.    
  545.     ReDim SReg_Values_Arr(0)
  546.    
  547.     With cRegistry
  548.         .ClassKey = enmClassKey
  549.         .SectionKey = strSectionKey
  550.         .EnumerateValues strValues(), lngKeyCount
  551.         ReDim SReg_Values_Arr(lngKeyCount)
  552.         For lngKeyIndex = 1 To lngKeyCount
  553.             SReg_Values_Arr(lngKeyIndex - 1).strKeyName = strValues(lngKeyIndex)
  554.             SReg_Values_Arr(lngKeyIndex - 1).varKeyValue = SReg_Get_StringValue(enmClassKey, _
  555.                                                                                 strSectionKey, _
  556.                                                                                 strValues(lngKeyIndex))
  557.         Next lngKeyIndex
  558.     End With
  559.    
  560.     SReg_Enm_Values = 1
  561.     Exit Function
  562. err_SReg_Enm_Values:    'error handler
  563.    SReg_Enm_Values = -1    'set internal error return
  564.    'send message to immediate window
  565.    Debug.Print Now & " | Function: & SReg_Enm_Values & | Error: #" & _
  566.                 Err.Number & vbTab & Err.Description
  567.     'if we want to show critical messages to the user
  568.    If blnErr_ShowCritical = True Then
  569.         'notify the user
  570.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  571.                vbCrLf & vbCrLf & Now, _
  572.                vbOKOnly + vbCritical, _
  573.                strMsgBoxTitle & " [Function: SReg_Enm_Values" & "]"
  574.     End If
  575.     Err.Clear    'clear the error object
  576. On Error Resume Next
  577.     'Cleanup
  578.    
  579. End Function
  580.  
  581. ' Module:       modRegistry.bas
  582. ' Function:     SReg_Get_BinaryValue
  583. ' Type:         Public
  584. ' By:           JA
  585. ' Desc:         Obtains a binary value from the registry
  586. ' Inputs:       enmClassKey             selected registry key
  587. '               strSectionKey           registry path to find value
  588. '               strSectionValue         registry section value
  589. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  590. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  591. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  592. ' Note:         None
  593. ' Example:
  594. '   SReg_bytArr = SReg_Get_BinaryValue(HKEY_LOCAL_MACHINE, "My Company\My Application\Settings", "Color Settings", "", True, True)
  595. '   -OR-
  596. '   SReg_bytArr = SReg_Get_BinaryValue(HKEY_LOCAL_MACHINE, "My Company\My Application\Settings", "Color Settings")
  597. Public Function SReg_Get_BinaryValue(enmClassKey As ERegistryClassConstants, _
  598.                                      strSectionKey As String, _
  599.                                      strSectionValue As String, _
  600.                                      Optional strMsgBoxTitle As String, _
  601.                                      Optional blnErr_ShowFriendly As Boolean, _
  602.                                      Optional blnErr_ShowCritical As Boolean _
  603.                                     ) As Variant
  604. On Error GoTo err_SReg_Get_BinaryValue    'initiate error handler
  605.    SReg_Get_BinaryValue = Nothing    'set default return
  606.    
  607.     Dim cRegistry       As New clsRegistry
  608.     Dim varRetVal       As Variant
  609.     Dim lngIndex        As Long
  610.    
  611.     If Left(strSectionKey, 1) = "\" Then _
  612.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  613.    
  614.     If Right(strSectionKey, 1) = "\" Then _
  615.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  616.    
  617.     strSectionValue = Trim(strSectionValue)
  618.    
  619.     With cRegistry
  620.         .ClassKey = enmClassKey
  621.         .SectionKey = strSectionKey
  622.         .ValueKey = strSectionValue
  623.        
  624.         varRetVal = .Value
  625.        
  626.         Select Case .ValueType
  627.             Case REG_BINARY
  628.                 For lngIndex = LBound(varRetVal) To UBound(varRetVal)
  629.                     SReg_Get_BinaryValue = SReg_Get_BinaryValue & "&H"
  630.                     If (lngIndex < &H10) Then SReg_Get_BinaryValue = SReg_Get_BinaryValue & "0"
  631.                     SReg_Get_BinaryValue = SReg_Get_BinaryValue & Hex$(varRetVal(lngIndex)) & " "
  632.                 Next lngIndex
  633.                
  634.             Case Else
  635.                 SReg_Get_BinaryValue = varRetVal
  636.         End Select
  637.     End With
  638.    
  639.     Exit Function
  640. err_SReg_Get_BinaryValue:    'error handler
  641.    SReg_Get_BinaryValue = Nothing    'set internal error return
  642.    'send message to immediate window
  643.    Debug.Print Now & " | Function: & SReg_Get_BinaryValue & | Error: #" & _
  644.                 Err.Number & vbTab & Err.Description
  645.     'if we want to show critical messages to the user
  646.    If blnErr_ShowCritical = True Then
  647.         'notify the user
  648.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  649.                vbCrLf & vbCrLf & Now, _
  650.                vbOKOnly + vbCritical, _
  651.                strMsgBoxTitle & " [Function: SReg_Get_BinaryValue" & "]"
  652.     End If
  653.     Err.Clear    'clear the error object
  654. On Error Resume Next
  655.     'Cleanup
  656.    
  657. End Function
  658.  
  659. ' Module:       modRegistry.bas
  660. ' Function:     SReg_Get_ComboBoxContents
  661. ' Type:         Public
  662. ' By:           JA
  663. ' Desc:         Retrieves the contents of a ComboBox from the registry
  664. ' Inputs:       enmClassKey             selected registry key
  665. '               strSectionKey           registry path to get value
  666. '               cboCombobox As ComboBox The ComboBox to reference
  667. '               lngMaxItems As Long     Optional Value: Default is -1 (No Limit). Zero or higher will limit the list
  668. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  669. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  670. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  671. ' Returns:
  672. '               -1      Internal error occured
  673. '                0      Information not added
  674. '                1      Information added successfully
  675. ' Note:         None
  676. ' Example:
  677. '   Dim lngRetVal As Long
  678. '   lngRetVal = SReg_Get_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo, -1, "", True, True)
  679. '   -OR-
  680. '   lngRetVal = SReg_Get_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo)
  681. Public Function SReg_Get_ComboBoxContents(enmClassKey As ERegistryClassConstants, _
  682.                                           strSectionKey As String, _
  683.                                           cboComboBox As ComboBox, _
  684.                                           Optional lngMaxItems As Long = -1, _
  685.                                           Optional strErr_MsgBoxTitle As String, _
  686.                                           Optional blnErr_ShowFriendly As Boolean, _
  687.                                           Optional blnErr_ShowCritical As Boolean _
  688.                                          ) As Long
  689. On Error GoTo err_SReg_Get_ComboBoxContents    'initiate error handler
  690.    SReg_Get_ComboBoxContents = 0    'set default return
  691.    
  692.     Dim strValueKey         As String
  693.     Dim lngIndex            As Long
  694.     Dim strContents         As String
  695.     Dim strRegRetVal        As String
  696.    
  697.     'Dim lngRetVal As Long
  698.    'lngRetVal = SReg_Enm_Values(HKEY_CURRENT_USER, "Testing\Combo1", SReg_Values_Arr, "", True, True)
  699.    'If lngRetVal > 0 Then
  700.    '    For lngIndex = 0 To UBound(SReg_Values_Arr) - 1
  701.    '        cboCombobox.AddItem SReg_Values_Arr(lngIndex).strKeyName & " - " & SReg_Values_Arr(lngIndex).varKeyValue
  702.    '    Next lngIndex
  703.    'End If
  704.    'Exit Function
  705.    
  706.     strRegRetVal = SReg_Get_StringValue(enmClassKey, strSectionKey, "MaxItems")
  707.     If Len(strRegRetVal) > 0 Then
  708.         If IsNumeric(strRegRetVal) Then
  709.             lngMaxItems = strRegRetVal
  710.         Else
  711.             SReg_Get_ComboBoxContents = -2
  712.             Exit Function
  713.         End If
  714.     Else
  715.         SReg_Get_ComboBoxContents = -3
  716.         Exit Function
  717.     End If
  718.    
  719.     For lngIndex = 1 To lngMaxItems
  720.         strValueKey = lngIndex
  721.         strContents = SReg_Get_StringValue(enmClassKey, strSectionKey, strValueKey)
  722.         If Len(Trim(strContents)) > 0 Then cboComboBox.AddItem strContents
  723.     Next lngIndex
  724.    
  725.     SReg_Get_ComboBoxContents = 1
  726. Exit Function
  727. err_SReg_Get_ComboBoxContents:    'error handler
  728.    SReg_Get_ComboBoxContents = -1    'set internal error return
  729.    Debug.Print Now & " | Function: & SReg_Get_ComboBoxContents & | Error: #" & Err.Number & vbTab & Err.Description    'send message to immediate window
  730.    If blnErr_ShowCritical = True Then  'if we want to show critical messages to the user
  731.        Select Case MsgBox("Error: #" & Err.Number & vbTab & Err.Description & vbTab & _
  732.                            vbCrLf & vbCrLf & Now & _
  733.                            vbCrLf & vbCrLf & "(Use Ctrl+C to copy this message.)", _
  734.                            vbAbortRetryIgnore + vbCritical, _
  735.                            strErr_MsgBoxTitle & " [Function: SReg_Get_ComboBoxContents - " & Err.Source & "]")
  736.             Case vbAbort:     Exit Function
  737.             Case vbRetry:     Resume
  738.             Case vbIgnore:    Resume Next
  739.         End Select
  740.     End If
  741.     Err.Clear    'clear the error object
  742. On Error Resume Next
  743.     'Cleanup
  744.    
  745. End Function
  746.  
  747. ' Module:       modRegistry.bas
  748. ' Function:     SReg_Get_List
  749. ' Type:         Public
  750. ' By:           JA
  751. ' Desc:         Retrieves the list items of a ComboBox or ListBox
  752. ' Inputs:       enmClassKey             selected registry key
  753. '               ctlControl              ComboBox or ListBox
  754. '               blnRestoreLastPos       Optional Value: if 'True' then will select the last selected item
  755. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  756. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  757. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  758. ' Returns:
  759. '               -1      Internal error occured
  760. '                0      Information not obtained
  761. '                1      Information obtained successfully
  762. ' Note:         None
  763. ' Example:
  764. '   Dim lngRetVal As Long
  765. '   lngRetVal = SReg_Get_List(HKEY_LOCAL_MACHINE, ComboBox1, True, "", True, True)
  766. '   -OR-
  767. '   lngRetVal = SReg_Get_List(HKEY_LOCAL_MACHINE, ComboBox1)
  768. Public Function SReg_Get_List(enmClassKey As ERegistryClassConstants, _
  769.                               ctlControl As Object, _
  770.                               Optional blnRestoreLastPos As Boolean, _
  771.                               Optional strMsgBoxTitle As String, _
  772.                               Optional blnErr_ShowFriendly As Boolean, _
  773.                               Optional blnErr_ShowCritical As Boolean _
  774.                              ) As Long
  775. On Error GoTo err_SReg_Get_List    'initiate error handler
  776.    SReg_Get_List = 0    'set default return
  777.    
  778.     Dim lngListIndex                As Long
  779.     Dim strListIndex                As String
  780.     Dim lngListCount                As Long
  781.     Dim strRegRetVal                As String
  782.     Dim lngSelIndex                 As Long
  783.     Dim strS_Reg_Path_Lists         As String
  784.    
  785.     strS_Reg_Path_Lists = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Lists\" & ctlControl.Name
  786.    
  787.     strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_Lists, "Max Items")
  788.     If IsNumeric(strRegRetVal) = True Then
  789.         lngListCount = strRegRetVal
  790.     Else
  791.         Exit Function
  792.     End If
  793.    
  794.     If blnRestoreLastPos = True Then
  795.         strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_Lists, "Curr Item")
  796.         If IsNumeric(strRegRetVal) = True Then lngSelIndex = strRegRetVal
  797.     End If
  798.    
  799.     Select Case TypeName(ctlControl)
  800.         Case "ComboBox", "ListBox"
  801.             For lngListIndex = 0 To lngListCount - 1
  802.                 strListIndex = lngListIndex
  803.                 strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_Lists, strListIndex)
  804.                 If Len(strRegRetVal) > 0 Then ctlControl.AddItem strRegRetVal
  805.             Next lngListIndex
  806.     End Select
  807.    
  808.     If blnRestoreLastPos = True Then If lngSelIndex > ctlControl.ListCount Then lngSelIndex = 0
  809.     ctlControl.ListIndex = lngSelIndex
  810.    
  811.     SReg_Get_List = 1
  812.     Exit Function
  813. err_SReg_Get_List:    'error handler
  814.    SReg_Get_List = -1    'set internal error return
  815.    'send message to immediate window
  816.    Debug.Print Now & " | Function: & SReg_Get_List & | Error: #" & _
  817.                 Err.Number & vbTab & Err.Description
  818.     'if we want to show critical messages to the user
  819.    If blnErr_ShowCritical = True Then
  820.         'notify the user
  821.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  822.                vbCrLf & vbCrLf & Now, _
  823.                vbOKOnly + vbCritical, _
  824.                strMsgBoxTitle & " [Function: SReg_Get_List" & "]"
  825.     End If
  826.     Err.Clear    'clear the error object
  827. On Error Resume Next
  828.     'Cleanup
  829.    
  830. End Function
  831.  
  832. ' Module:       modRegistry.bas
  833. ' Function:     SReg_Get_Metrics_Form
  834. ' Type:         Public
  835. ' By:           JA
  836. ' Desc:         Retrieves the metrics and view options of a form
  837. ' Inputs:       enmClassKey             selected registry key
  838. '               frmForm                 form to obtain values for
  839. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  840. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  841. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  842. ' Returns:
  843. '               -1      Internal error occured
  844. '                0      Information not obtained
  845. '                1      Information obtained successfully
  846. ' Note:         None
  847. ' Example:
  848. '   Dim lngRetVal As Long
  849. '   lngRetVal = SReg_Get_Metrics_Form(HKEY_LOCAL_MACHINE, Form1, "", True, True)
  850. '   -OR-
  851. '   lngRetVal = SReg_Get_Metrics_Form(HKEY_LOCAL_MACHINE, Form1)
  852. Public Function SReg_Get_Metrics_Form(enmClassKey As ERegistryClassConstants, _
  853.                                       frmForm As Form, _
  854.                                       Optional strMsgBoxTitle As String, _
  855.                                       Optional blnErr_ShowFriendly As Boolean, _
  856.                                       Optional blnErr_ShowCritical As Boolean _
  857.                                      ) As Long
  858. On Error GoTo err_SReg_Get_Metrics_Form    'initiate error handler
  859.    SReg_Get_Metrics_Form = 0    'set default return
  860.    
  861.     Dim cRegistry                   As New clsRegistry
  862.     Dim lngForm_WindowState         As Long
  863.     Dim lngForm_Left                As Long
  864.     Dim lngForm_Top                 As Long
  865.     Dim lngForm_Width               As Long
  866.     Dim lngForm_Height              As Long
  867.     Dim strS_Reg_Path_Form          As String
  868.    
  869.     strS_Reg_Path_Form = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name
  870.    
  871.     With cRegistry
  872.         .ClassKey = enmClassKey
  873.         .SectionKey = strS_Reg_Path_Form
  874.         .ValueType = REG_DWORD
  875.         .ValueKey = "WindowState":      lngForm_WindowState = .Value
  876.         .ValueKey = "Left":             lngForm_Left = .Value
  877.         .ValueKey = "Top":              lngForm_Top = .Value
  878.         .ValueKey = "Width":            lngForm_Width = .Value
  879.         .ValueKey = "Height":           lngForm_Height = .Value
  880.     End With
  881.    
  882.     With frmForm
  883.         If lngForm_Width <> 0 Then .Width = lngForm_Width
  884.         If lngForm_Height <> 0 Then .Height = lngForm_Height
  885.         If lngForm_WindowState = 0 Then
  886.             .Move (Screen.Width - .Width) / 2, (Screen.Height - .Height) / 2
  887.         Else
  888.             If lngForm_Left < 0 Then lngForm_Left = (Screen.Width - .Width) / 2
  889.             If (lngForm_Left - -lngForm_Width) > Screen.Width Then lngForm_Left = (Screen.Width - .Width) / 2
  890.             If lngForm_Top < 0 Then lngForm_Top = (Screen.Height - .Height) / 2
  891.             If (lngForm_Top - -lngForm_Height) > Screen.Height Then lngForm_Top = (Screen.Height - .Height) / 2
  892.             .WindowState = lngForm_WindowState
  893.         End If
  894.         If lngForm_Left <> 0 Then .Left = lngForm_Left
  895.         If lngForm_Top <> 0 Then .Top = lngForm_Top
  896.     End With
  897.    
  898.     SReg_Get_Metrics_Form = 1
  899.     Set cRegistry = Nothing
  900.     Exit Function
  901. err_SReg_Get_Metrics_Form:    'error handler
  902.    SReg_Get_Metrics_Form = -1    'set internal error return
  903.    'send message to immediate window
  904.    Debug.Print Now & " | Function: & SReg_Get_Metrics_Form & | Error: #" & _
  905.                 Err.Number & vbTab & Err.Description
  906.     'if we want to show critical messages to the user
  907.    If blnErr_ShowCritical = True Then
  908.         'notify the user
  909.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  910.                vbCrLf & vbCrLf & Now, _
  911.                vbOKOnly + vbCritical, _
  912.                strMsgBoxTitle & " [Function: SReg_Get_Metrics_Form" & "]"
  913.     End If
  914.     Err.Clear    'clear the error object
  915. On Error Resume Next
  916.     'Cleanup
  917.    
  918. End Function
  919.  
  920. ' Module:       modRegistry.bas
  921. ' Function:     SReg_Get_Metrics_ListView
  922. ' Type:         Public
  923. ' By:           JA
  924. ' Desc:         Retrieves the metrics and options for a ListView
  925. ' Inputs:       enmClassKey             selected registry key
  926. '               frmForm                 form where ListView resides
  927. '               lvwListView             name of ListView
  928. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  929. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  930. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  931. ' Returns:
  932. '               -1      Internal error occured
  933. '                0      Information not obtained
  934. '                1      Information obtained successfully
  935. ' Note:         None
  936. ' Example:
  937. '   Dim lngRetVal As Long
  938. '   lngRetVal = SReg_Get_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1, "", True, True)
  939. '   -OR-
  940. '   lngRetVal = SReg_Get_Metrics_ListView(HKEY_LOCAL_MACHINE, Form1, ListView1)
  941. Public Function SReg_Get_Metrics_ListView(enmClassKey As ERegistryClassConstants, _
  942.                                           frmForm As Form, _
  943.                                           lvwListView As ListView, _
  944.                                           Optional strMsgBoxTitle As String, _
  945.                                           Optional blnErr_ShowFriendly As Boolean, _
  946.                                           Optional blnErr_ShowCritical As Boolean _
  947.                                          ) As Long
  948. On Error GoTo err_SReg_Get_Metrics_ListView    'initiate error handler
  949.    SReg_Get_Metrics_ListView = 0    'set default return
  950.    
  951.     Dim cRegistry                   As New clsRegistry
  952.     Dim lngColIndex                 As Long
  953.     Dim varRetVal                   As Variant
  954.     Dim strS_Reg_Path_ListView      As String
  955.    
  956.     strS_Reg_Path_ListView = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name & "\" & lvwListView.Name
  957.    
  958.     With cRegistry
  959.         .ClassKey = enmClassKey
  960.         .ValueType = REG_SZ
  961.     End With
  962.    
  963.     With lvwListView
  964.         cRegistry.SectionKey = strS_Reg_Path_ListView
  965.         cRegistry.ValueKey = "AllowColumnReorder":      varRetVal = cRegistry.Value
  966.         If varRetVal = "True" Then .AllowColumnReorder = True Else .AllowColumnReorder = False
  967.         cRegistry.ValueKey = "Checkboxes":              varRetVal = cRegistry.Value
  968.         If varRetVal = "True" Then .Checkboxes = True Else .Checkboxes = False
  969.         cRegistry.ValueKey = "FullRowSelect":           varRetVal = cRegistry.Value
  970.         If varRetVal = "True" Then .FullRowSelect = True Else .FullRowSelect = False
  971.         cRegistry.ValueKey = "HideSelection":           varRetVal = cRegistry.Value
  972.         If varRetVal = "True" Then .HideSelection = True Else .HideSelection = False
  973.         cRegistry.ValueKey = "HotTracking":             varRetVal = cRegistry.Value
  974.         If varRetVal = "True" Then .HotTracking = True Else .HotTracking = False
  975.         cRegistry.ValueKey = "HoverSelection":          varRetVal = cRegistry.Value
  976.         If varRetVal = "True" Then .HoverSelection = True Else .HoverSelection = False
  977.         cRegistry.ValueType = REG_DWORD
  978.         cRegistry.ValueKey = "LabelEdit":               varRetVal = cRegistry.Value
  979.         If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .LabelEdit = varRetVal
  980.         cRegistry.ValueType = REG_SZ
  981.         cRegistry.ValueKey = "LabelWrap":               varRetVal = cRegistry.Value
  982.         If varRetVal = "True" Then .LabelWrap = True Else .LabelWrap = False
  983.         cRegistry.ValueKey = "MultiSelect":             varRetVal = cRegistry.Value
  984.         If varRetVal = "True" Then .MultiSelect = True Else .MultiSelect = False
  985.         cRegistry.ValueKey = "Sorted":                  varRetVal = cRegistry.Value
  986.         If varRetVal = "True" Then .Sorted = True Else .Sorted = False
  987.         cRegistry.ValueType = REG_DWORD
  988.         cRegistry.ValueKey = "SortKey":                 varRetVal = cRegistry.Value
  989.         If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .SortKey = varRetVal
  990.         cRegistry.ValueKey = "SortOrder":               varRetVal = cRegistry.Value
  991.         If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .SortOrder = varRetVal
  992.         cRegistry.ValueKey = "View":                    varRetVal = cRegistry.Value
  993.         If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .View = varRetVal
  994.     End With
  995.    
  996.     If lvwListView.ColumnHeaders.Count < 1 Then Exit Function
  997.    
  998.     With lvwListView.ColumnHeaders
  999.         For lngColIndex = 1 To lvwListView.ColumnHeaders.Count
  1000.             cRegistry.SectionKey = strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text
  1001.             cRegistry.ValueType = REG_DWORD
  1002.             cRegistry.ValueKey = "Alignment":           varRetVal = cRegistry.Value
  1003.             If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .Item(lngColIndex).Alignment = varRetVal
  1004.             cRegistry.ValueKey = "Position":            varRetVal = cRegistry.Value
  1005.             If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .Item(lngColIndex).Position = varRetVal
  1006.             cRegistry.ValueType = REG_SZ
  1007.             cRegistry.ValueKey = "Width":               varRetVal = cRegistry.Value
  1008.             If Not IsEmpty(varRetVal) = True Then If IsNumeric(varRetVal) = True Then .Item(lngColIndex).Width = varRetVal
  1009.         Next lngColIndex
  1010.     End With
  1011.    
  1012.     SReg_Get_Metrics_ListView = 1
  1013.     Set cRegistry = Nothing
  1014.     Exit Function
  1015. err_SReg_Get_Metrics_ListView:    'error handler
  1016.    SReg_Get_Metrics_ListView = -1    'set internal error return
  1017.    'send message to immediate window
  1018.    Debug.Print Now & " | Function: & SReg_Get_Metrics_ListView & | " & frmForm.Name & "." & lvwListView.Name & " Error: #" & _
  1019.                 Err.Number & vbTab & Err.Description
  1020.     'if we want to show critical messages to the user
  1021.    If blnErr_ShowCritical = True Then
  1022.         'notify the user
  1023.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1024.                vbCrLf & vbCrLf & Now, _
  1025.                vbOKOnly + vbCritical, _
  1026.                strMsgBoxTitle & " [Function: SReg_Get_Metrics_ListView" & "]"
  1027.     End If
  1028.     Err.Clear    'clear the error object
  1029. On Error Resume Next
  1030.     'Cleanup
  1031.    
  1032. End Function
  1033.  
  1034. ' Module:       modRegistry.bas
  1035. ' Function:     SReg_Get_NumericValue
  1036. ' Type:         Public
  1037. ' By:           JA
  1038. ' Desc:         Returns a numeric value from the registry
  1039. ' Inputs:       enmClassKey             selected registry key
  1040. '               strSectionKey           registry path to find value
  1041. '               strSectionValue         registry section value
  1042. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1043. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1044. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1045. ' Note:         None
  1046. ' Example:
  1047. '   Dim lngRetVal As Long
  1048. '   lngRetVal = SReg_Get_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "IconIndex", "", True, True)
  1049. '   -OR-
  1050. '   lngRetVal = SReg_Get_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "IconIndex")
  1051. Public Function SReg_Get_NumericValue(enmClassKey As ERegistryClassConstants, _
  1052.                                       strSectionKey As String, _
  1053.                                       strSectionValue As String, _
  1054.                                       Optional strMsgBoxTitle As String, _
  1055.                                       Optional blnErr_ShowFriendly As Boolean, _
  1056.                                       Optional blnErr_ShowCritical As Boolean _
  1057.                                      ) As Long
  1058. On Error GoTo err_SReg_Get_NumericValue    'initiate error handler
  1059.    SReg_Get_NumericValue = 0    'set default return
  1060.    
  1061.     Dim cRegistry     As New clsRegistry
  1062.    
  1063.     If Left(strSectionKey, 1) = "\" Then _
  1064.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  1065.    
  1066.     If Right(strSectionKey, 1) = "\" Then _
  1067.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  1068.    
  1069.     strSectionValue = Trim(strSectionValue)
  1070.    
  1071.     With cRegistry
  1072.         .ClassKey = enmClassKey
  1073.         .SectionKey = strSectionKey
  1074.         .ValueKey = strSectionValue
  1075.         .ValueType = REG_DWORD
  1076.         SReg_Get_NumericValue = .Value
  1077.     End With
  1078.    
  1079.     Set cRegistry = Nothing
  1080.     SReg_Get_NumericValue = 1
  1081.     Exit Function
  1082. err_SReg_Get_NumericValue:    'error handler
  1083.    SReg_Get_NumericValue = -1    'set internal error return
  1084.    'send message to immediate window
  1085.    Debug.Print Now & " | Function: & SReg_Get_NumericValue & | Error: #" & _
  1086.                 Err.Number & vbTab & Err.Description
  1087.     'if we want to show critical messages to the user
  1088.    If blnErr_ShowCritical = True Then
  1089.         'notify the user
  1090.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1091.                vbCrLf & vbCrLf & Now, _
  1092.                vbOKOnly + vbCritical, _
  1093.                strMsgBoxTitle & " [Function: SReg_Get_NumericValue" & "]"
  1094.     End If
  1095.     Err.Clear    'clear the error object
  1096. On Error Resume Next
  1097.     'Cleanup
  1098.    
  1099. End Function
  1100.  
  1101. ' Module:       modRegistry.bas
  1102. ' Function:     SReg_Get_ODBCData
  1103. ' Type:         Public
  1104. ' By:           JA
  1105. ' Desc:         Returns a filled SReg_ODBCData object with the corresponding data from the connection
  1106. ' Inputs:       blnLocal                Local Variable: If True then HKEY_LOCAL_MACHINE else HKEY_CURRENT_USER
  1107. '               strConnectionName       Name fo the connection to look for
  1108. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1109. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1110. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1111. ' Note:         None
  1112. ' Example:
  1113. '   Dim typSReg_ODBCData As SReg_ODBCData
  1114. '   typSReg_ODBCData = SReg_Get_ODBCData(True, "MyConnection", "", True, True)
  1115. '   -OR-
  1116. '   typSReg_ODBCData = SReg_Get_ODBCData(True, "MyConnection")
  1117. Public Function SReg_Get_ODBCData(blnLocal As Boolean, _
  1118.                                   strConnectionName As String, _
  1119.                                   Optional strMsgBoxTitle As String, _
  1120.                                   Optional blnErr_ShowFriendly As Boolean, _
  1121.                                   Optional blnErr_ShowCritical As Boolean _
  1122.                                  ) As SReg_ODBCData
  1123. On Error GoTo err_SReg_Get_ODBCData    'initiate error handler
  1124.    
  1125.     Dim enmLocalClassKey            As ERegistryClassConstants
  1126.     Dim strRegRetVal                As String
  1127.     Dim strODBCINI                  As String
  1128.    
  1129.     strODBCINI = "SOFTWARE\ODBC\ODBC.INI\"
  1130.    
  1131.     'clean data
  1132.    strConnectionName = Trim(strConnectionName)
  1133.    
  1134.     'validate data
  1135.    If Len(strConnectionName) = 0 Then
  1136.         'send message to immediate window
  1137.        Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & _
  1138.                     "Connection Name Not Specified"
  1139.         'if we want to show friendly messages to the user
  1140.        If blnErr_ShowFriendly Then
  1141.             MsgBox "Error: " & "Connection Name Not Specified" & _
  1142.                    vbCrLf & vbCrLf & Now, _
  1143.                    vbOKOnly + vbInformation, _
  1144.                    strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
  1145.         End If
  1146.         Exit Function
  1147.     End If
  1148.    
  1149.     Select Case blnLocal
  1150.         Case True:      enmLocalClassKey = HKEY_CURRENT_USER
  1151.         Case False:     enmLocalClassKey = HKEY_LOCAL_MACHINE
  1152.     End Select
  1153.    
  1154.     'get data
  1155.    With SReg_Get_ODBCData
  1156.         .strConnectionName = strConnectionName
  1157.         strRegRetVal = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & "ODBC Data Sources", strConnectionName))
  1158.         Select Case UCase(strConnectionName)
  1159.             Case "CR DB2":                                  .enmSReg_ODBC_ServerType = sReg_ST_CRDB2
  1160.             Case "CR INFORMIX":                             .enmSReg_ODBC_ServerType = sReg_ST_CRInformix
  1161.             Case "CR ORACLE7":                              .enmSReg_ODBC_ServerType = sReg_ST_CROracle7
  1162.             Case "CR SQLBASE":                              .enmSReg_ODBC_ServerType = sReg_ST_CRSQLBase
  1163.             Case "CR SYBASE SYSTEM 10":                     .enmSReg_ODBC_ServerType = sReg_ST_CRSybaseSystem10
  1164.             Case "MICROSOFT FOXPRO VFP DRIVER (*.DBF)":     .enmSReg_ODBC_ServerType = sReg_ST_FoxProVFP_DBF
  1165.             Case "MICROSOFT ACCESS DRIVER (*.MDB)":         .enmSReg_ODBC_ServerType = sReg_ST_MSAccess_MDB
  1166.             Case "MICROSOFT DBASE DRIVER (*.DBF)":          .enmSReg_ODBC_ServerType = sReg_ST_MSdBase_DBF
  1167.             Case "MICROSOFT DBASE VFP DRIVER (*.DBF)":      .enmSReg_ODBC_ServerType = sReg_ST_MSdBaseVFP_DBF
  1168.             Case "MICROSOFT EXCEL DRIVER (*.XLS)":          .enmSReg_ODBC_ServerType = sReg_ST_MSExcel_XLS
  1169.             Case "MICROSOFT FOXPRO DRIVER (*.DBF)":         .enmSReg_ODBC_ServerType = sReg_ST_MSFoxPro_DBF
  1170.             Case "MICROSOFT ODBC FOR ORACLE":               .enmSReg_ODBC_ServerType = sReg_ST_MSODBCforOracle
  1171.             Case "MICROSOFT PARADOX DRIVER (*.DB )":        .enmSReg_ODBC_ServerType = sReg_ST_MSParadox_DB
  1172.             Case "MICROSOFT TEXT DRIVER (*.TXT; *.CSV)":    .enmSReg_ODBC_ServerType = sReg_ST_MSText_TXT_CSV
  1173.             Case "MICROSOFT VISUAL FOXPRO DRIVER (*.DBF)":  .enmSReg_ODBC_ServerType = sReg_ST_MSVisualFoxPro_DBF
  1174.             Case "MICROSOFT VISUAL FOXPRO DRIVER":          .enmSReg_ODBC_ServerType = sReg_ST_MSVisualFoxPro_General
  1175.             Case "SQL SERVER":                              .enmSReg_ODBC_ServerType = sReg_ST_SQLServer
  1176.         End Select
  1177.         .strDatabase = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Database"))
  1178.         .strDescription = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Description"))
  1179.         .strDriver = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Driver"))
  1180.         .strLastUser = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "LastUser"))
  1181.         .strServer = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Server"))
  1182.         strRegRetVal = Trim(SReg_Get_StringValue(enmLocalClassKey, strODBCINI & strConnectionName, "Trusted_Connection"))
  1183.         Select Case UCase(strRegRetVal)
  1184.             Case "YES":     .blnTrustedConnection = True
  1185.             Case Else:      .blnTrustedConnection = False
  1186.         End Select
  1187.     End With
  1188.    
  1189.     Exit Function
  1190. err_SReg_Get_ODBCData:    'error handler
  1191.    'send message to immediate window
  1192.    Debug.Print Now & " | Function: & SReg_Get_ODBCData & | Error: #" & _
  1193.                 Err.Number & vbTab & Err.Description
  1194.     'if we want to show critical messages to the user
  1195.    If blnErr_ShowCritical = True Then
  1196.         'notify the user
  1197.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1198.                vbCrLf & vbCrLf & Now, _
  1199.                vbOKOnly + vbCritical, _
  1200.                strMsgBoxTitle & " [Function: SReg_Get_ODBCData" & "]"
  1201.     End If
  1202.     Err.Clear    'clear the error object
  1203. On Error Resume Next
  1204.     'Cleanup
  1205.    
  1206. End Function
  1207.  
  1208. ' Module:       modRegistry.bas
  1209. ' Function:     SReg_Get_Program_CompanyName
  1210. ' Type:         Public
  1211. ' By:           JA
  1212. ' Desc:         Returns the Company Name from the project (or exe) properties
  1213. ' Inputs:       strMsgBoxTitle          Optional Value: Title to use in error MsgBox's
  1214. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1215. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1216. ' Note:         Internally this is used for registry paths
  1217. ' Example:
  1218. '   Dim strRetVal As String
  1219. '   strRetVal = SReg_Get_Program_CompanyName("", True, True)
  1220. '   -OR-
  1221. '   strRetVal = SReg_Get_Program_CompanyName
  1222. '   strRetVal now contains: "Company Name"
  1223. Public Function SReg_Get_Program_CompanyName(Optional strMsgBoxTitle As String, _
  1224.                                              Optional blnErr_ShowFriendly As Boolean, _
  1225.                                              Optional blnErr_ShowCritical As Boolean _
  1226.                                             ) As String
  1227. On Error GoTo err_SReg_Get_Program_CompanyName    'initiate error handler
  1228.    SReg_Get_Program_CompanyName = vbNullString    'set default return
  1229.    
  1230.     SReg_Get_Program_CompanyName = Trim(App.CompanyName)
  1231.     If Len(SReg_Get_Program_CompanyName) < 1 Then SReg_Get_Program_CompanyName = "Miscellaneous"
  1232.    
  1233.     Exit Function
  1234. err_SReg_Get_Program_CompanyName:    'error handler
  1235.    SReg_Get_Program_CompanyName = vbNullString    'set internal error return
  1236.    'send message to immediate window
  1237.    Debug.Print Now & " | Function: & SReg_Get_Program_CompanyName & | Error: #" & _
  1238.                 Err.Number & vbTab & Err.Description
  1239.     'if we want to show critical messages to the user
  1240.    If blnErr_ShowCritical = True Then
  1241.         'notify the user
  1242.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1243.                vbCrLf & vbCrLf & Now, _
  1244.                vbOKOnly + vbCritical, _
  1245.                strMsgBoxTitle & " [Function: SReg_Get_Program_CompanyName" & "]"
  1246.     End If
  1247.     Err.Clear    'clear the error object
  1248. On Error Resume Next
  1249.     'Cleanup
  1250.    
  1251. End Function
  1252.  
  1253. ' Module:       modRegistry.bas
  1254. ' Function:     SReg_Get_Program_Last_Close
  1255. ' Type:         Public
  1256. ' By:           JA
  1257. ' Desc:         Returns the last date and time that the program was closed
  1258. ' Inputs:       enmClassKey             selected registry key
  1259. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1260. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1261. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1262. ' Note:         None
  1263. ' Example:
  1264. '   Dim strRetVal As String
  1265. '   strRetVal = SReg_Get_Program_Last_Close(HKEY_LOCAL_MACHINE, "", True, True)
  1266. '   -OR-
  1267. '   strRetVal = SReg_Get_Program_Last_Close(HKEY_LOCAL_MACHINE)
  1268. Public Function SReg_Get_Program_Last_Close(enmClassKey As ERegistryClassConstants, _
  1269.                                             Optional strMsgBoxTitle As String, _
  1270.                                             Optional blnErr_ShowFriendly As Boolean, _
  1271.                                             Optional blnErr_ShowCritical As Boolean _
  1272.                                            ) As String
  1273. On Error GoTo err_SReg_Get_Program_Last_Close    'initiate error handler
  1274.    SReg_Get_Program_Last_Close = vbNullString    'set default return
  1275.    
  1276.     Dim strS_Reg_Path_ProgInfo      As String
  1277.    
  1278.     strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
  1279.    
  1280.     SReg_Get_Program_Last_Close = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Last Closed")
  1281.    
  1282.     Exit Function
  1283. err_SReg_Get_Program_Last_Close:    'error handler
  1284.    SReg_Get_Program_Last_Close = vbNullString    'set internal error return
  1285.    'send message to immediate window
  1286.    Debug.Print Now & " | Function: & SReg_Get_Program_Last_Close & | Error: #" & _
  1287.                 Err.Number & vbTab & Err.Description
  1288.     'if we want to show critical messages to the user
  1289.    If blnErr_ShowCritical = True Then
  1290.         'notify the user
  1291.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1292.                vbCrLf & vbCrLf & Now, _
  1293.                vbOKOnly + vbCritical, _
  1294.                strMsgBoxTitle & " [Function: SReg_Get_Program_Last_Close" & "]"
  1295.     End If
  1296.     Err.Clear    'clear the error object
  1297. On Error Resume Next
  1298.     'Cleanup
  1299.    
  1300. End Function
  1301.  
  1302. ' Module:       modRegistry.bas
  1303. ' Function:     SReg_Get_Program_Last_Run
  1304. ' Type:         Public
  1305. ' By:           JA
  1306. ' Desc:         Returns the last date and time that the program was run
  1307. ' Inputs:       enmClassKey             selected registry key
  1308. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1309. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1310. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1311. ' Note:         None
  1312. ' Example:
  1313. '   Dim strRetVal As String
  1314. '   strRetVal = SReg_Get_Program_Last_Run(HKEY_LOCAL_MACHINE, "", True, True)
  1315. '   -OR-
  1316. '   strRetVal = SReg_Get_Program_Last_Run(HKEY_LOCAL_MACHINE)
  1317. Public Function SReg_Get_Program_Last_Run(enmClassKey As ERegistryClassConstants, _
  1318.                                           Optional strMsgBoxTitle As String, _
  1319.                                           Optional blnErr_ShowFriendly As Boolean, _
  1320.                                           Optional blnErr_ShowCritical As Boolean _
  1321.                                          ) As String
  1322. On Error GoTo err_SReg_Get_Program_Last_Run    'initiate error handler
  1323.    SReg_Get_Program_Last_Run = vbNullString    'set default return
  1324.    
  1325.     Dim strS_Reg_Path_ProgInfo      As String
  1326.    
  1327.     strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
  1328.    
  1329.     SReg_Get_Program_Last_Run = SReg_Get_StringValue(HKEY_CURRENT_USER, strS_Reg_Path_ProgInfo, "Last Run")
  1330.    
  1331.     Exit Function
  1332. err_SReg_Get_Program_Last_Run:    'error handler
  1333.    SReg_Get_Program_Last_Run = vbNullString    'set internal error return
  1334.    'send message to immediate window
  1335.    Debug.Print Now & " | Function: & SReg_Get_Program_Last_Run & | Error: #" & _
  1336.                 Err.Number & vbTab & Err.Description
  1337.     'if we want to show critical messages to the user
  1338.    If blnErr_ShowCritical = True Then
  1339.         'notify the user
  1340.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1341.                vbCrLf & vbCrLf & Now, _
  1342.                vbOKOnly + vbCritical, _
  1343.                strMsgBoxTitle & " [Function: SReg_Get_Program_Last_Run" & "]"
  1344.     End If
  1345.     Err.Clear    'clear the error object
  1346. On Error Resume Next
  1347.     'Cleanup
  1348.    
  1349. End Function
  1350.  
  1351. ' Module:       modRegistry.bas
  1352. ' Function:     SReg_Get_Program_LastVersion
  1353. ' Type:         Public
  1354. ' By:           JA
  1355. ' Desc:         Returns the application version from the registry
  1356. ' Inputs:       enmClassKey             selected registry key
  1357. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1358. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1359. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1360. ' Note:         Use this before using 'SReg_Set_Program_Info' to see if the application has been updated
  1361. '               If you change the size of a form in an update you would want to delete the metric settings
  1362. '                   and maybe some other options on the first run
  1363. ' Example:
  1364. '   Dim strRetVal As Long
  1365. '   Dim strCurrAppVer As String
  1366. '   strRetVal = SReg_Get_Program_LastVersion(HKEY_LOCAL_MACHINE, "", True, True)
  1367. '    strCurrAppVer = App.Major & "." & App.Minor & "." & App.Revision
  1368. '    If strRetVal <> strCurrAppVer Then
  1369. '       '[insert code here]
  1370. '    End If
  1371. Public Function SReg_Get_Program_LastVersion(enmClassKey As ERegistryClassConstants, _
  1372.                                              Optional strMsgBoxTitle As String, _
  1373.                                              Optional blnErr_ShowFriendly As Boolean, _
  1374.                                              Optional blnErr_ShowCritical As Boolean _
  1375.                                             ) As String
  1376. On Error GoTo err_SReg_Get_Program_LastVersion    'initiate error handler
  1377.    SReg_Get_Program_LastVersion = vbNullString    'set default return
  1378.    
  1379.     Dim strAppMajor                 As String
  1380.     Dim strAppMinor                 As String
  1381.     Dim strAppRevision              As String
  1382.     Dim strS_Reg_Path_ProgInfo      As String
  1383.    
  1384.     strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
  1385.    
  1386.     strAppMajor = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Major")
  1387.     strAppMinor = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Minor")
  1388.     strAppRevision = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Revision")
  1389.    
  1390.     SReg_Get_Program_LastVersion = strAppMajor & "." & strAppMinor & "." & strAppRevision
  1391.    
  1392.     Exit Function
  1393. err_SReg_Get_Program_LastVersion:    'error handler
  1394.    SReg_Get_Program_LastVersion = vbNullString    'set internal error return
  1395.    'send message to immediate window
  1396.    Debug.Print Now & " | Function: & SReg_Get_Program_LastVersion & | Error: #" & _
  1397.                 Err.Number & vbTab & Err.Description
  1398.     'if we want to show critical messages to the user
  1399.    If blnErr_ShowCritical = True Then
  1400.         'notify the user
  1401.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1402.                vbCrLf & vbCrLf & Now, _
  1403.                vbOKOnly + vbCritical, _
  1404.                strMsgBoxTitle & " [Function: SReg_Get_Program_LastVersion" & "]"
  1405.     End If
  1406.     Err.Clear    'clear the error object
  1407. On Error Resume Next
  1408.     'Cleanup
  1409.    
  1410. End Function
  1411.  
  1412. ' Module:       modRegistry.bas
  1413. ' Function:     SReg_Get_Program_TotalTimesRun
  1414. ' Type:         Public
  1415. ' By:           JA
  1416. ' Desc:         Returns the number of times a program has been run
  1417. ' Inputs:       enmClassKey             selected registry key
  1418. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1419. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1420. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1421. ' Note:         None
  1422. ' Example:
  1423. '   Dim lngRetVal As Long
  1424. '   lngRetVal = SReg_Get_Program_TotalTimesRun(HKEY_LOCAL_MACHINE, "", True, True)
  1425. '   -OR-
  1426. '   lngRetVal = SReg_Get_Program_TotalTimesRun(HKEY_LOCAL_MACHINE)
  1427. Public Function SReg_Get_Program_TotalTimesRun(enmClassKey As ERegistryClassConstants, _
  1428.                                                Optional strMsgBoxTitle As String, _
  1429.                                                Optional blnErr_ShowFriendly As Boolean, _
  1430.                                                Optional blnErr_ShowCritical As Boolean _
  1431.                                               ) As Long
  1432. On Error GoTo err_SReg_Get_Program_TotalTimesRun    'initiate error handler
  1433.    SReg_Get_Program_TotalTimesRun = 0    'set default return
  1434.    
  1435.     Dim strS_Reg_Path_ProgInfo      As String
  1436.    
  1437.     strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
  1438.    
  1439.     SReg_Get_Program_TotalTimesRun = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Total Times Run")
  1440.    
  1441.     Exit Function
  1442. err_SReg_Get_Program_TotalTimesRun:    'error handler
  1443.    SReg_Get_Program_TotalTimesRun = -1    'set internal error return
  1444.    'send message to immediate window
  1445.    Debug.Print Now & " | Function: & SReg_Get_Program_TotalTimesRun & | Error: #" & _
  1446.                 Err.Number & vbTab & Err.Description
  1447.     'if we want to show critical messages to the user
  1448.    If blnErr_ShowCritical = True Then
  1449.         'notify the user
  1450.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1451.                vbCrLf & vbCrLf & Now, _
  1452.                vbOKOnly + vbCritical, _
  1453.                strMsgBoxTitle & " [Function: SReg_Get_Program_TotalTimesRun" & "]"
  1454.     End If
  1455.     Err.Clear    'clear the error object
  1456. On Error Resume Next
  1457.     'Cleanup
  1458.    
  1459. End Function
  1460.  
  1461. ' Module:       modRegistry.bas
  1462. ' Function:     SReg_Get_StringValue
  1463. ' Type:         Public
  1464. ' By:           JA
  1465. ' Desc:         Returns a string value from the registry
  1466. ' Inputs:       enmClassKey             selected registry key
  1467. '               strSectionKey           registry path to find value
  1468. '               strSectionValue         registry section value
  1469. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1470. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1471. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1472. ' Note:         None
  1473. ' Example:
  1474. '   Dim strRetVal As String
  1475. '   strRetVal = SReg_Get_StringValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "Tray ToolTipText", "", True, True)
  1476. '   -OR-
  1477. '   strRetVal = SReg_Get_StringValue(HKEY_LOCAL_MACHINE, "Software\My Company\My App\Settings", "Tray ToolTipText")
  1478. Public Function SReg_Get_StringValue(enmClassKey As ERegistryClassConstants, _
  1479.                                      strSectionKey As String, _
  1480.                                      strSectionValue As String, _
  1481.                                      Optional strMsgBoxTitle As String, _
  1482.                                      Optional blnErr_ShowFriendly As Boolean, _
  1483.                                      Optional blnErr_ShowCritical As Boolean _
  1484.                                     ) As String
  1485. On Error GoTo err_SReg_Get_StringValue    'initiate error handler
  1486.    SReg_Get_StringValue = vbNullString    'set default return
  1487.    
  1488.     Dim cRegistry     As New clsRegistry
  1489.    
  1490.     If Left(strSectionKey, 1) = "\" Then _
  1491.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  1492.    
  1493.     If Right(strSectionKey, 1) = "\" Then _
  1494.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  1495.    
  1496.     strSectionValue = Trim(strSectionValue)
  1497.    
  1498.     With cRegistry
  1499.         .ClassKey = enmClassKey
  1500.         .SectionKey = strSectionKey
  1501.         .ValueKey = strSectionValue
  1502.         .ValueType = REG_SZ
  1503.         SReg_Get_StringValue = .Value
  1504.     End With
  1505.    
  1506.     Set cRegistry = Nothing
  1507.     Exit Function
  1508. err_SReg_Get_StringValue:    'error handler
  1509.    SReg_Get_StringValue = vbNullString    'set internal error return
  1510.    'send message to immediate window
  1511.    Debug.Print Now & " | Function: & SReg_Get_StringValue & | Error: #" & _
  1512.                 Err.Number & vbTab & Err.Description
  1513.     'if we want to show critical messages to the user
  1514.    If blnErr_ShowCritical = True Then
  1515.         'notify the user
  1516.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1517.                vbCrLf & vbCrLf & Now, _
  1518.                vbOKOnly + vbCritical, _
  1519.                strMsgBoxTitle & " [Function: SReg_Get_StringValue" & "]"
  1520.     End If
  1521.     Err.Clear    'clear the error object
  1522. On Error Resume Next
  1523.     'Cleanup
  1524.    
  1525. End Function
  1526.  
  1527. ' Module:       modRegistry.bas
  1528. ' Function:     SReg_Set_BinaryValue
  1529. ' Type:         Public
  1530. ' By:           JA
  1531. ' Desc:         Saves a binary value to the registry
  1532. ' Inputs:       enmClassKey             selected registry key
  1533. '               strSectionKey           registry path to find value
  1534. '               strSectionValue         registry section value
  1535. '               SReg_bytArr()           Array containing the byte(s) to add
  1536. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1537. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1538. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1539. ' Returns:
  1540. '               -1      Internal error occured
  1541. '                0      Information not added
  1542. '                1      Information added successfully
  1543. ' Note:         None
  1544. ' Example:
  1545. '   Dim lngRetVal As Long
  1546. '   lngRetVal = SReg_Set_BinaryValue(HKEY_CURRENT_USER, "Software\My Company\My App", "Color Settings", SReg_bytArr, "", True, True)
  1547. '   -OR-
  1548. '   lngRetVal = SReg_Set_BinaryValue(HKEY_CURRENT_USER, "Software\My Company\My App", "Color Settings", SReg_bytArr)
  1549. Public Function SReg_Set_BinaryValue(enmClassKey As ERegistryClassConstants, _
  1550.                                      strSectionKey As String, _
  1551.                                      strSectionValue As String, _
  1552.                                      ByRef SReg_bytArr() As Byte, _
  1553.                                      Optional strMsgBoxTitle As String, _
  1554.                                      Optional blnErr_ShowFriendly As Boolean, _
  1555.                                      Optional blnErr_ShowCritical As Boolean _
  1556.                                     ) As Long
  1557. On Error GoTo err_SReg_Set_BinaryValue    'initiate error handler
  1558.    SReg_Set_BinaryValue = 0    'set default return
  1559.    
  1560.     Dim cRegistry       As New clsRegistry
  1561.    
  1562.     If Left(strSectionKey, 1) = "\" Then _
  1563.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  1564.    
  1565.     If Right(strSectionKey, 1) = "\" Then _
  1566.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  1567.    
  1568.     strSectionValue = Trim(strSectionValue)
  1569.    
  1570.     With cRegistry
  1571.         .ClassKey = HKEY_CURRENT_USER
  1572.         .SectionKey = strSectionKey
  1573.         .ValueKey = strSectionValue
  1574.         .ValueType = REG_BINARY
  1575.         .Value = SReg_bytArr()
  1576.     End With
  1577.    
  1578.     SReg_Set_BinaryValue = 1
  1579.     Exit Function
  1580. err_SReg_Set_BinaryValue:    'error handler
  1581.    SReg_Set_BinaryValue = -1    'set internal error return
  1582.    'send message to immediate window
  1583.    Debug.Print Now & " | Function: & SReg_Set_BinaryValue & | Error: #" & _
  1584.                 Err.Number & vbTab & Err.Description
  1585.     'if we want to show critical messages to the user
  1586.    If blnErr_ShowCritical = True Then
  1587.         'notify the user
  1588.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1589.                vbCrLf & vbCrLf & Now, _
  1590.                vbOKOnly + vbCritical, _
  1591.                strMsgBoxTitle & " [Function: SReg_Set_BinaryValue" & "]"
  1592.     End If
  1593.     Err.Clear    'clear the error object
  1594. On Error Resume Next
  1595.     'Cleanup
  1596.    
  1597. End Function
  1598.  
  1599. ' Module:       modRegistry.bas
  1600. ' Function:     SReg_Set_ComboBoxContents
  1601. ' Type:         Public
  1602. ' By:           JA
  1603. ' Desc:         Saves the contents of a ComboBox to the registry
  1604. ' Inputs:       enmClassKey             selected registry key
  1605. '               strSectionKey           registry path to set value
  1606. '               cboCombobox As ComboBox The ComboBox to reference
  1607. '               lngMaxItems As Long     Optional Value: Default is -1 (No Limit). Zero or higher will limit the list
  1608. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1609. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1610. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1611. ' Returns:
  1612. '               -1      Internal error occured
  1613. '                0      Information not added
  1614. '                1      Information added successfully
  1615. ' Note:         None
  1616. ' Example:
  1617. '   Dim lngRetVal As Long
  1618. '   lngRetVal = SReg_Set_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo, -1, "", True, True)
  1619. '   -OR-
  1620. '   lngRetVal = SReg_Set_ComboBoxContents(HKEY_CURRENT_USER, "Software\My Company\My App", "ComboLists", cboMyCombo)
  1621. Public Function SReg_Set_ComboBoxContents(enmClassKey As ERegistryClassConstants, _
  1622.                                           strSectionKey As String, _
  1623.                                           cboComboBox As ComboBox, _
  1624.                                           Optional lngMaxItems As Long = -1, _
  1625.                                           Optional strErr_MsgBoxTitle As String, _
  1626.                                           Optional blnErr_ShowFriendly As Boolean, _
  1627.                                           Optional blnErr_ShowCritical As Boolean _
  1628.                                          ) As Long
  1629. On Error GoTo err_SReg_Set_ComboBoxContents    'initiate error handler
  1630.    SReg_Set_ComboBoxContents = 0    'set default return
  1631.    
  1632.     Dim strValueKey         As String
  1633.     Dim lngIndex            As Long
  1634.     Dim strContents         As String
  1635.    
  1636.     If lngMaxItems = 0 Then
  1637.         SReg_Set_ComboBoxContents = 1
  1638.         Exit Function
  1639.     End If
  1640.    
  1641.     strContents = cboComboBox.ListCount
  1642.     SReg_Set_StringValue enmClassKey, strSectionKey, "MaxItems", strContents
  1643.    
  1644.     If lngMaxItems = -1 Then lngMaxItems = cboComboBox.ListCount
  1645.    
  1646.     'lngIndex = cboCombobox.ListCount
  1647.    'Do Until lngIndex = 0
  1648.    For lngIndex = 1 To cboComboBox.ListCount
  1649.         If lngIndex <= lngMaxItems Then
  1650.             cboComboBox.ListIndex = lngIndex - 1
  1651.             strContents = cboComboBox.Text
  1652.             strValueKey = lngIndex
  1653.             SReg_Set_StringValue enmClassKey, strSectionKey, strValueKey, strContents
  1654.         Else
  1655.             Exit For
  1656.         End If
  1657.     Next lngIndex
  1658.     '    lngIndex = lngIndex - 1
  1659.    'Loop
  1660.    
  1661.     SReg_Set_ComboBoxContents = 1
  1662. Exit Function
  1663. err_SReg_Set_ComboBoxContents:    'error handler
  1664.    SReg_Set_ComboBoxContents = -1    'set internal error return
  1665.    Debug.Print Now & " | Function: & SReg_Set_ComboBoxContents & | Error: #" & Err.Number & vbTab & Err.Description    'send message to immediate window
  1666.    If blnErr_ShowCritical = True Then  'if we want to show critical messages to the user
  1667.        Select Case MsgBox("Error: #" & Err.Number & vbTab & Err.Description & vbTab & _
  1668.                            vbCrLf & vbCrLf & Now & _
  1669.                            vbCrLf & vbCrLf & "(Use Ctrl+C to copy this message.)", _
  1670.                            vbAbortRetryIgnore + vbCritical, _
  1671.                            strErr_MsgBoxTitle & " [Function: SReg_Set_ComboBoxContents - " & Err.Source & "]")
  1672.             Case vbAbort:     Exit Function
  1673.             Case vbRetry:     Resume
  1674.             Case vbIgnore:    Resume Next
  1675.         End Select
  1676.     End If
  1677.     Err.Clear    'clear the error object
  1678. On Error Resume Next
  1679.     'Cleanup
  1680.    
  1681. End Function
  1682.  
  1683. ' Module:       modRegistry.bas
  1684. ' Function:     SReg_Set_List
  1685. ' Type:         Public
  1686. ' By:           JA
  1687. ' Desc:         Saves a list from a ComboBox or a ListBox
  1688. ' Inputs:       enmClassKey             selected registry key
  1689. '               ctlControl              ComboBox or ListBox
  1690. '               blnSaveLastPos          Optional Value: if 'True' then will save last selected item
  1691. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1692. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1693. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1694. ' Returns:
  1695. '               -1      Internal error occured
  1696. '                0      Information not added
  1697. '                1      Information added successfully
  1698. ' Note:         None
  1699. ' Example:
  1700. '   Dim lngRetVal As Long
  1701. '   lngRetVal = SReg_Set_List(HKEY_CURRENT_USER, lstListBox, True, "", True, True)
  1702. '   -OR-
  1703. '   lngRetVal = SReg_Set_List(HKEY_CURRENT_USER, lstListBox, True)
  1704. Public Function SReg_Set_List(enmClassKey As ERegistryClassConstants, _
  1705.                               ctlControl As Object, _
  1706.                               Optional blnSaveLastPos As Boolean, _
  1707.                               Optional strMsgBoxTitle As String, _
  1708.                               Optional blnErr_ShowFriendly As Boolean, _
  1709.                               Optional blnErr_ShowCritical As Boolean _
  1710.                              ) As Long
  1711. On Error GoTo err_SReg_Set_List    'initiate error handler
  1712.    SReg_Set_List = 0    'set default return
  1713.    
  1714.     Dim lngListIndex                As Long
  1715.     Dim strListIndex                As String
  1716.     Dim strS_Reg_Path_Lists         As String
  1717.    
  1718.     strS_Reg_Path_Lists = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Lists\" & ctlControl.Name
  1719.    
  1720.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_Lists, "Max Items", ctlControl.ListCount
  1721.    
  1722.     If blnSaveLastPos = True Then SReg_Set_StringValue enmClassKey, strS_Reg_Path_Lists, "Curr Item", ctlControl.ListIndex
  1723.    
  1724.     Select Case TypeName(ctlControl)
  1725.         Case "ComboBox", "ListBox"
  1726.             For lngListIndex = 0 To ctlControl.ListCount - 1
  1727.                 ctlControl.ListIndex = lngListIndex
  1728.                 strListIndex = lngListIndex
  1729.                 SReg_Set_StringValue enmClassKey, strS_Reg_Path_Lists, strListIndex, ctlControl.Text
  1730.             Next lngListIndex
  1731.     End Select
  1732.    
  1733.     SReg_Set_List = 1
  1734.     Exit Function
  1735. err_SReg_Set_List:    'error handler
  1736.    SReg_Set_List = -1    'set internal error return
  1737.    'send message to immediate window
  1738.    Debug.Print Now & " | Function: & SReg_Set_List & | Error: #" & _
  1739.                 Err.Number & vbTab & Err.Description
  1740.     'if we want to show critical messages to the user
  1741.    If blnErr_ShowCritical = True Then
  1742.         'notify the user
  1743.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1744.                vbCrLf & vbCrLf & Now, _
  1745.                vbOKOnly + vbCritical, _
  1746.                strMsgBoxTitle & " [Function: SReg_Set_List" & "]"
  1747.     End If
  1748.     Err.Clear    'clear the error object
  1749. On Error Resume Next
  1750.     'Cleanup
  1751.    
  1752. End Function
  1753.  
  1754. ' Module:       modRegistry.bas
  1755. ' Function:     SReg_Set_Metrics_Form
  1756. ' Type:         Public
  1757. ' By:           JA
  1758. ' Desc:         Stores the metrics of a form an the view options
  1759. ' Inputs:       enmClassKey             selected registry key
  1760. '               frmForm                 form that ListView resides on
  1761. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1762. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1763. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1764. ' Returns:
  1765. '               -1      Internal error occured
  1766. '                0      Information not added
  1767. '                1      Information added successfully
  1768. ' Note:         None
  1769. ' Example:
  1770. '   Dim lngRetVal As Long
  1771. '   lngRetVal = SReg_Set_Metrics_Form(HKEY_CURRENT_USER, Form1, "", True, True)
  1772. '   -OR-
  1773. '   lngRetVal = SReg_Set_Metrics_Form(HKEY_CURRENT_USER, Form1)
  1774. Public Function SReg_Set_Metrics_Form(enmClassKey As ERegistryClassConstants, _
  1775.                                       frmForm As Form, _
  1776.                                       Optional strMsgBoxTitle As String, _
  1777.                                       Optional blnErr_ShowFriendly As Boolean, _
  1778.                                       Optional blnErr_ShowCritical As Boolean _
  1779.                                      ) As Long
  1780. On Error GoTo err_SReg_Set_Metrics_Form    'initiate error handler
  1781.    SReg_Set_Metrics_Form = 0    'set default return
  1782.    
  1783.     Dim cRegistry               As New clsRegistry
  1784.     Dim lngForm_Left            As Long
  1785.     Dim lngForm_Top             As Long
  1786.     Dim lngForm_Width           As Long
  1787.     Dim lngForm_Height          As Long
  1788.     Dim strS_Reg_Path_Form      As String
  1789.    
  1790.     strS_Reg_Path_Form = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name
  1791.    
  1792.     lngForm_Left = frmForm.Left
  1793.     lngForm_Top = frmForm.Top
  1794.     lngForm_Width = frmForm.Width
  1795.     lngForm_Height = frmForm.Height
  1796.    
  1797.     With cRegistry
  1798.         .ClassKey = enmClassKey
  1799.         .SectionKey = strS_Reg_Path_Form
  1800.         .ValueType = REG_DWORD
  1801.        
  1802.         Select Case frmForm.WindowState
  1803.             Case vbMaximized
  1804.                 .ValueKey = "WindowState":      .Value = frmForm.WindowState
  1805.                
  1806.             Case vbMinimized
  1807.                 .ValueKey = "WindowState":      .Value = frmForm.WindowState
  1808.                
  1809.             Case Else
  1810.                 .ValueKey = "WindowState":      .Value = frmForm.WindowState
  1811.                 .ValueKey = "Left":             .Value = lngForm_Left
  1812.                 .ValueKey = "Top":              .Value = lngForm_Top
  1813.                 .ValueKey = "Width":            .Value = lngForm_Width
  1814.                 .ValueKey = "Height":           .Value = lngForm_Height
  1815.                
  1816.         End Select
  1817.     End With
  1818.    
  1819.     SReg_Set_Metrics_Form = 1
  1820.     Set cRegistry = Nothing
  1821.     Exit Function
  1822. err_SReg_Set_Metrics_Form:    'error handler
  1823.    SReg_Set_Metrics_Form = -1    'set internal error return
  1824.    'send message to immediate window
  1825.    Debug.Print Now & " | Function: & SReg_Set_Metrics_Form & | Error: #" & _
  1826.                 Err.Number & vbTab & Err.Description
  1827.     'if we want to show critical messages to the user
  1828.    If blnErr_ShowCritical = True Then
  1829.         'notify the user
  1830.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1831.                vbCrLf & vbCrLf & Now, _
  1832.                vbOKOnly + vbCritical, _
  1833.                strMsgBoxTitle & " [Function: SReg_Set_Metrics_Form" & "]"
  1834.     End If
  1835.     Err.Clear    'clear the error object
  1836. On Error Resume Next
  1837.     'Cleanup
  1838.    
  1839. End Function
  1840.  
  1841. ' Module:       modRegistry.bas
  1842. ' Function:     SReg_Set_Metrics_ListView
  1843. ' Type:         Public
  1844. ' By:           JA
  1845. ' Desc:         Stores the metrics and options of a ListView
  1846. ' Inputs:       enmClassKey             selected registry key
  1847. '               frmForm                 form that ListView resides on
  1848. '               lvwListView             name of ListView
  1849. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1850. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1851. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1852. ' Returns:
  1853. '               -1      Internal error occured
  1854. '                0      Information not added
  1855. '                1      Information added successfully
  1856. ' Note:         None
  1857. ' Example:
  1858. '   Dim lngRetVal As Long
  1859. '   lngRetVal = SReg_Set_Metrics_ListView(HKEY_CURRENT_USER, Form1, ListView1, "", True, True)
  1860. '   -OR-
  1861. '   lngRetVal = SReg_Set_Metrics_ListView(HKEY_CURRENT_USER, Form1, ListView1)
  1862. Public Function SReg_Set_Metrics_ListView(enmClassKey As ERegistryClassConstants, _
  1863.                                           frmForm As Form, _
  1864.                                           lvwListView As ListView, _
  1865.                                           Optional strMsgBoxTitle As String, _
  1866.                                           Optional blnErr_ShowFriendly As Boolean, _
  1867.                                           Optional blnErr_ShowCritical As Boolean _
  1868.                                          ) As Long
  1869. On Error GoTo err_SReg_Set_Metrics_ListView    'initiate error handler
  1870.    SReg_Set_Metrics_ListView = 0    'set default return
  1871.    
  1872.     Dim cRegistry                   As New clsRegistry
  1873.     Dim lngColIndex                 As Long
  1874.     Dim strS_Reg_Path_ListView      As String
  1875.    
  1876.     strS_Reg_Path_ListView = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Metrics\" & frmForm.Name & "\" & lvwListView.Name
  1877.    
  1878.     With cRegistry
  1879.         .ClassKey = enmClassKey
  1880.         .ValueType = REG_SZ
  1881.     End With
  1882.    
  1883.     With lvwListView
  1884.         cRegistry.SectionKey = strS_Reg_Path_ListView
  1885.         cRegistry.ValueKey = "AllowColumnReorder":      cRegistry.Value = .AllowColumnReorder
  1886.         cRegistry.ValueKey = "Checkboxes":              cRegistry.Value = .Checkboxes
  1887.         cRegistry.ValueKey = "FullRowSelect":           cRegistry.Value = .FullRowSelect
  1888.         cRegistry.ValueKey = "HideSelection":           cRegistry.Value = .HideSelection
  1889.         cRegistry.ValueKey = "HotTracking":             cRegistry.Value = .HotTracking
  1890.         cRegistry.ValueKey = "HoverSelection":          cRegistry.Value = .HoverSelection
  1891.         cRegistry.ValueType = REG_DWORD
  1892.         cRegistry.ValueKey = "LabelEdit":               cRegistry.Value = .LabelEdit
  1893.         cRegistry.ValueType = REG_SZ
  1894.         cRegistry.ValueKey = "LabelWrap":               cRegistry.Value = .LabelWrap
  1895.         cRegistry.ValueKey = "MultiSelect":             cRegistry.Value = .MultiSelect
  1896.         cRegistry.ValueKey = "Sorted":                  cRegistry.Value = .Sorted
  1897.         cRegistry.ValueType = REG_DWORD
  1898.         cRegistry.ValueKey = "SortKey":                 cRegistry.Value = .SortKey
  1899.         cRegistry.ValueKey = "SortOrder":               cRegistry.Value = .SortOrder
  1900.         cRegistry.ValueKey = "View":                    cRegistry.Value = .View
  1901.     End With
  1902.    
  1903.     If lvwListView.ColumnHeaders.Count < 1 Then Exit Function
  1904.    
  1905.     With lvwListView.ColumnHeaders
  1906.         For lngColIndex = 1 To lvwListView.ColumnHeaders.Count
  1907.             cRegistry.SectionKey = strS_Reg_Path_ListView & "\" & .Item(lngColIndex).Text
  1908.             cRegistry.ValueType = REG_DWORD
  1909.             cRegistry.ValueKey = "Alignment":       cRegistry.Value = .Item(lngColIndex).Alignment
  1910.             cRegistry.ValueKey = "Position":        cRegistry.Value = .Item(lngColIndex).Position
  1911.             cRegistry.ValueType = REG_SZ
  1912.             cRegistry.ValueKey = "Width":           cRegistry.Value = .Item(lngColIndex).Width
  1913.         Next lngColIndex
  1914.     End With
  1915.    
  1916.     SReg_Set_Metrics_ListView = 1
  1917.     Set cRegistry = Nothing
  1918.     Exit Function
  1919. err_SReg_Set_Metrics_ListView:    'error handler
  1920.    SReg_Set_Metrics_ListView = -1    'set internal error return
  1921.    'send message to immediate window
  1922.    Debug.Print Now & " | Function: & SReg_Set_Metrics_ListView & | " & frmForm.Name & "." & lvwListView.Name & " Error: #" & _
  1923.                 Err.Number & vbTab & Err.Description
  1924.     'if we want to show critical messages to the user
  1925.    If blnErr_ShowCritical = True Then
  1926.         'notify the user
  1927.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  1928.                vbCrLf & vbCrLf & Now, _
  1929.                vbOKOnly + vbCritical, _
  1930.                strMsgBoxTitle & " [Function: SReg_Set_Metrics_ListView" & "]"
  1931.     End If
  1932.     Err.Clear    'clear the error object
  1933. On Error Resume Next
  1934.     'Cleanup
  1935.    
  1936. End Function
  1937.  
  1938. ' Module:       modRegistry.bas
  1939. ' Function:     SReg_Set_NumericValue
  1940. ' Type:         Public
  1941. ' By:           JA
  1942. ' Desc:         Adds a numeric value to the registry
  1943. ' Inputs:       enmClassKey             selected registry key
  1944. '               strSectionKey           registry path to find value
  1945. '               strValueKey             registry key to add value to
  1946. '               lngSectionValue         value to add
  1947. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  1948. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  1949. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  1950. ' Returns:
  1951. '               -1      Internal error occured
  1952. '                0      Information not added
  1953. '                1      Information added successfully
  1954. ' Note:         None
  1955. ' Example:
  1956. '   Dim lngRetVal As Long
  1957. '   lngRetVal = SReg_Set_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company", "Copyright", 2001, "", True, True)
  1958. '   -OR-
  1959. '   lngRetVal = SReg_Set_NumericValue(HKEY_LOCAL_MACHINE, "Software\My Company", "Copyright", 2001)
  1960. Public Function SReg_Set_NumericValue(enmClassKey As ERegistryClassConstants, _
  1961.                                       strSectionKey As String, _
  1962.                                       strValueKey As String, _
  1963.                                       lngSectionValue As Long, _
  1964.                                       Optional strMsgBoxTitle As String, _
  1965.                                       Optional blnErr_ShowFriendly As Boolean, _
  1966.                                       Optional blnErr_ShowCritical As Boolean _
  1967.                                      ) As Long
  1968. On Error GoTo err_SReg_Set_NumericValue    'initiate error handler
  1969.    SReg_Set_NumericValue = 0    'set default return
  1970.    
  1971.     Dim cRegistry       As New clsRegistry
  1972.    
  1973.     If Left(strSectionKey, 1) = "\" Then _
  1974.         strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  1975.    
  1976.     If Right(strSectionKey, 1) = "\" Then _
  1977.         strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  1978.    
  1979.     strValueKey = Trim(strValueKey)
  1980.    
  1981.     With cRegistry
  1982.         .ClassKey = enmClassKey
  1983.         .SectionKey = strSectionKey
  1984.         .ValueType = REG_DWORD
  1985.         .ValueKey = strValueKey
  1986.         .Value = lngSectionValue
  1987.     End With
  1988.    
  1989.     SReg_Set_NumericValue = 1
  1990.     Set cRegistry = Nothing
  1991.     Exit Function
  1992. err_SReg_Set_NumericValue:    'error handler
  1993.    SReg_Set_NumericValue = -1    'set internal error return
  1994.    'send message to immediate window
  1995.    Debug.Print Now & " | Function: & SReg_Set_NumericValue & | Error: #" & _
  1996.                 Err.Number & vbTab & Err.Description
  1997.     'if we want to show critical messages to the user
  1998.    If blnErr_ShowCritical = True Then
  1999.         'notify the user
  2000.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2001.                vbCrLf & vbCrLf & Now, _
  2002.                vbOKOnly + vbCritical, _
  2003.                strMsgBoxTitle & " [Function: SReg_Set_NumericValue" & "]"
  2004.     End If
  2005.     Err.Clear    'clear the error object
  2006. On Error Resume Next
  2007.     'Cleanup
  2008.    
  2009. End Function
  2010.  
  2011. ' Module:       modRegistry.bas
  2012. ' Function:     SReg_Set_ODBCData
  2013. ' Type:         Public
  2014. ' By:           JA
  2015. ' Desc:         Creates/Updates an ODBC Connection
  2016. ' Inputs:       typSReg_ODBCData        SReg_ODBCData object
  2017. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  2018. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  2019. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  2020. ' Note:         None
  2021. ' Returns
  2022. '    1      Successful Create or Update
  2023. '    0      Nothing to do
  2024. '   -1      Internal Function Error
  2025. '   -2      Connection Name Not Specified
  2026. '   -3      Database Not Specified
  2027. '   -4      Driver Not Specified
  2028. '   -5      Server Not Specified
  2029. ' Example:
  2030. '   Dim lngRetVal As Long
  2031. '   lngRetVal = SReg_Set_ODBCData(typODBCData, True, "", True, True)
  2032. '   -OR-
  2033. '   lngRetVal = SReg_Set_ODBCData(typODBCData, True)
  2034. Public Function SReg_Set_ODBCData(ByRef typODBCData As SReg_ODBCData, _
  2035.                                   Optional blnAutoResetObject As Boolean, _
  2036.                                   Optional strMsgBoxTitle As String, _
  2037.                                   Optional blnErr_ShowFriendly As Boolean, _
  2038.                                   Optional blnErr_ShowCritical As Boolean _
  2039.                                  ) As Long
  2040. On Error GoTo err_SReg_Set_ODBCData    'initiate error handler
  2041.    SReg_Set_ODBCData = 0    'set default return
  2042.    
  2043.     Dim enmLocalClassKey            As ERegistryClassConstants
  2044.     Dim strTrustedConnection        As String
  2045.     Dim strServerType               As String
  2046.     Dim strRegRetVal                As String
  2047.     Dim strODBCINI                  As String
  2048.    
  2049.     strODBCINI = "SOFTWARE\ODBC\ODBC.INI\"
  2050.    
  2051.     With typODBCData
  2052.         'clean data_______________________________________________________________________________________________
  2053.        .strConnectionName = Trim(.strConnectionName)
  2054.         .strDatabase = Trim(.strDatabase)
  2055.         .strDescription = Trim(.strDescription)
  2056.         .strDriver = Trim(.strDriver)
  2057.         .strLastUser = UCase(Trim(.strLastUser))
  2058.         .strServer = UCase(Trim(.strServer))
  2059.        
  2060.         'resolve keys_____________________________________________________________________________________________
  2061.        Select Case typODBCData.blnLocal
  2062.             Case True:      enmLocalClassKey = HKEY_CURRENT_USER
  2063.             Case False:     enmLocalClassKey = HKEY_LOCAL_MACHINE
  2064.         End Select
  2065.        
  2066.         Select Case typODBCData.enmSReg_ODBC_ServerType
  2067.             Case sReg_ST_CRDB2:                     strServerType = "CR DB2"
  2068.             Case sReg_ST_CRInformix:                strServerType = "CR Informix"
  2069.             Case sReg_ST_CROracle7:                 strServerType = "CR Oracle7"
  2070.             Case sReg_ST_CRSQLBase:                 strServerType = "CR SQLBase"
  2071.             Case sReg_ST_CRSybaseSystem10:          strServerType = "CR Sybase System 10"
  2072.             Case sReg_ST_FoxProVFP_DBF:             strServerType = "Microsoft FoxPro VFP Driver (*.DBF)"
  2073.             Case sReg_ST_MSAccess_MDB:              strServerType = "Microsoft Access Driver (*.MDB)"
  2074.             Case sReg_ST_MSdBase_DBF:               strServerType = "Microsoft dBase Driver (*.DBF)"
  2075.             Case sReg_ST_MSdBaseVFP_DBF:            strServerType = "Microsoft dBase VFP Driver (*.DBF)"
  2076.             Case sReg_ST_MSExcel_XLS:               strServerType = "Microsoft Excel Driver (*.XLS)"
  2077.             Case sReg_ST_MSFoxPro_DBF:              strServerType = "Microsoft FoxPro Driver (*.DBF)"
  2078.             Case sReg_ST_MSODBCforOracle:           strServerType = "Microsoft ODBC for Oracle"
  2079.             Case sReg_ST_MSParadox_DB:              strServerType = "Microsoft Paradox Driver (*.DB )"
  2080.             Case sReg_ST_MSText_TXT_CSV:            strServerType = "Microsoft Text Driver (*.TXT; *.CSV)"
  2081.             Case sReg_ST_MSVisualFoxPro_DBF:        strServerType = "Microsoft Visual FoxPro Driver (*.DBF)"
  2082.             Case sReg_ST_MSVisualFoxPro_General:    strServerType = "Microsoft Visual FoxPro Driver "
  2083.             Case sReg_ST_SQLServer:                 strServerType = "SQL Server"
  2084.             Case Else:                              strServerType = "Not Supported"
  2085.         End Select
  2086.        
  2087.         Select Case typODBCData.blnTrustedConnection
  2088.             Case True:      strTrustedConnection = "Yes"
  2089.             Case Else:      strTrustedConnection = "No"
  2090.         End Select
  2091.        
  2092.         'validate data____________________________________________________________________________________________
  2093.        If Len(.strConnectionName) = 0 Then
  2094.             'send message to immediate window
  2095.            Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Connection Name Not Specified"
  2096.             'if we want to show friendly messages to the user
  2097.            If blnErr_ShowFriendly Then
  2098.                 MsgBox "Error: " & "Connection Name Not Specified" & _
  2099.                        vbCrLf & vbCrLf & Now, _
  2100.                        vbOKOnly + vbInformation, _
  2101.                        strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
  2102.             End If
  2103.             SReg_Set_ODBCData = -2
  2104.             Exit Function
  2105.         End If
  2106.         If Len(.strDatabase) = 0 Then
  2107.             'send message to immediate window
  2108.            Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Database Not Specified"
  2109.             'if we want to show friendly messages to the user
  2110.            If blnErr_ShowFriendly Then
  2111.                 MsgBox "Error: " & "Database not Specified" & _
  2112.                        vbCrLf & vbCrLf & Now, _
  2113.                        vbOKOnly + vbInformation, _
  2114.                        strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
  2115.             End If
  2116.             SReg_Set_ODBCData = -3
  2117.             Exit Function
  2118.         End If
  2119.         If Len(.strDriver) = 0 Then
  2120.             'if the driver is not given then attempt to look it up
  2121.            strRegRetVal = Trim(SReg_Get_StringValue(enmLocalClassKey, _
  2122.                                                      "SOFTWARE\ODBC\ODBCINST.INI\" & strServerType, _
  2123.                                                      "Driver"))
  2124.             If Len(strRegRetVal) = 0 Then
  2125.                 'send message to immediate window
  2126.                Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Driver not Specified"
  2127.                 'if we want to show friendly messages to the user
  2128.                If blnErr_ShowFriendly Then
  2129.                     MsgBox "Error: " & "Driver not Specified" & _
  2130.                            vbCrLf & vbCrLf & Now, _
  2131.                            vbOKOnly + vbInformation, _
  2132.                            strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
  2133.                 End If
  2134.                 SReg_Set_ODBCData = -4
  2135.                 Exit Function
  2136.             Else
  2137.                 .strDriver = strRegRetVal
  2138.             End If
  2139.         End If
  2140.         If Len(.strServer) = 0 Then
  2141.             'send message to immediate window
  2142.            Debug.Print Now & " | Function: & SReg_Set_ODBCData & | " & "Server Not Specified"
  2143.             'if we want to show friendly messages to the user
  2144.            If blnErr_ShowFriendly Then
  2145.                 MsgBox "Error: " & "Server Not Specified" & _
  2146.                        vbCrLf & vbCrLf & Now, _
  2147.                        vbOKOnly + vbInformation, _
  2148.                        strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
  2149.             End If
  2150.             SReg_Set_ODBCData = -5
  2151.             Exit Function
  2152.         End If
  2153.        
  2154.         'set data_________________________________________________________________________________________________
  2155.        SReg_Set_StringValue enmLocalClassKey, strODBCINI & "ODBC Data Sources", .strConnectionName, strServerType
  2156.         SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Database", .strDatabase
  2157.         SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Description", .strDescription
  2158.         SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Driver", .strDriver
  2159.         SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "LastUser", .strLastUser
  2160.         SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Server", .strServer
  2161.         SReg_Set_StringValue enmLocalClassKey, strODBCINI & .strConnectionName, "Trusted_Connection", strTrustedConnection
  2162.        
  2163.         'clear object_____________________________________________________________________________________________
  2164.        If blnAutoResetObject Then
  2165.             .blnLocal = False
  2166.             .blnTrustedConnection = False
  2167.             .enmSReg_ODBC_ServerType = 0
  2168.             .strConnectionName = ""
  2169.             .strDatabase = ""
  2170.             .strDescription = ""
  2171.             .strDriver = ""
  2172.             .strLastUser = ""
  2173.             .strServer = ""
  2174.         End If
  2175.     End With
  2176.    
  2177.     SReg_Set_ODBCData = 1
  2178.     Exit Function
  2179. err_SReg_Set_ODBCData:    'error handler
  2180.    SReg_Set_ODBCData = -1    'set internal error return
  2181.    'send message to immediate window
  2182.    Debug.Print Now & " | Function: & SReg_Set_ODBCData & | Error: #" & _
  2183.                 Err.Number & vbTab & Err.Description
  2184.     'if we want to show critical messages to the user
  2185.    If blnErr_ShowCritical = True Then
  2186.         'notify the user
  2187.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2188.                vbCrLf & vbCrLf & Now, _
  2189.                vbOKOnly + vbCritical, _
  2190.                strMsgBoxTitle & " [Function: SReg_Set_ODBCData" & "]"
  2191.     End If
  2192.     Err.Clear    'clear the error object
  2193. On Error Resume Next
  2194.     'Cleanup
  2195.    
  2196. End Function
  2197.  
  2198. ' Module:       modRegistry.bas
  2199. ' Function:     SReg_Set_Program_Info
  2200. ' Type:         Public
  2201. ' By:           JA
  2202. ' Desc:         Stores various Information about a program
  2203. ' Inputs:       enmClassKey             selected registry key
  2204. '               blnUnloading            Optional Value: if 'True' then will set unload information
  2205. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  2206. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  2207. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  2208. ' Returns:
  2209. '               -1      Internal error occured
  2210. '                0      Information not added
  2211. '                1      Information added successfully
  2212. ' Note:         None
  2213. ' Example:
  2214. '   Dim lngRetVal As String
  2215. '   lngRetVal = SReg_Set_Program_Info(HKEY_LOCAL_MACHINE, False, "", True, True)
  2216. '   -OR-
  2217. '   lngRetVal = SReg_Set_Program_Info(HKEY_LOCAL_MACHINE, False)
  2218. Public Function SReg_Set_Program_Info(enmClassKey As ERegistryClassConstants, _
  2219.                                       Optional blnUnloading As Boolean, _
  2220.                                       Optional strMsgBoxTitle As String, _
  2221.                                       Optional blnErr_ShowFriendly As Boolean, _
  2222.                                       Optional blnErr_ShowCritical As Boolean _
  2223.                                      ) As Long
  2224. On Error GoTo err_SReg_Set_Program_Info    'initiate error handler
  2225.    SReg_Set_Program_Info = 0    'set default return
  2226.    
  2227.     Dim strRegRetVal                As String
  2228.     Dim strTotalRun                 As String
  2229.     Dim strS_Reg_Path_ProgInfo      As String
  2230.    
  2231.     strS_Reg_Path_ProgInfo = "Software\" & SReg_Get_Program_CompanyName & "\" & App.Title & "\Program Information"
  2232.    
  2233.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Comments", App.Comments
  2234.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Company Name", App.CompanyName
  2235.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "EXE Name", App.EXEName
  2236.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "File Description", App.FileDescription
  2237.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Help File", App.HelpFile
  2238.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "hInstance", App.hInstance
  2239.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Legal Copyright", App.LegalCopyright
  2240.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Legal Trademarks", App.LegalTrademarks
  2241.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Major", App.Major
  2242.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Minor", App.Minor
  2243.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Path", App.Path
  2244.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Product Name", App.ProductName
  2245.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Revision", App.Revision
  2246.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Thread Id", App.ThreadID
  2247.     SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Title", App.Title
  2248.     If blnUnloading = True Then
  2249.         SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Last Closed", Now
  2250.         strRegRetVal = SReg_Get_StringValue(enmClassKey, strS_Reg_Path_ProgInfo, "Total Times Run")
  2251.         If IsNumeric(strRegRetVal) = True Then strTotalRun = strRegRetVal - -1 Else strTotalRun = 1
  2252.         SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Total Times Run", strTotalRun
  2253.     Else
  2254.         SReg_Set_StringValue enmClassKey, strS_Reg_Path_ProgInfo, "Last Run", Now
  2255.     End If
  2256.    
  2257.     SReg_Set_Program_Info = 1
  2258.     Exit Function
  2259. err_SReg_Set_Program_Info:    'error handler
  2260.    SReg_Set_Program_Info = -1    'set internal error return
  2261.    'send message to immediate window
  2262.    Debug.Print Now & " | Function: & SReg_Set_Program_Info & | Error: #" & _
  2263.                 Err.Number & vbTab & Err.Description
  2264.     'if we want to show critical messages to the user
  2265.    If blnErr_ShowCritical = True Then
  2266.         'notify the user
  2267.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2268.                vbCrLf & vbCrLf & Now, _
  2269.                vbOKOnly + vbCritical, _
  2270.                strMsgBoxTitle & " [Function: SReg_Set_Program_Info" & "]"
  2271.     End If
  2272.     Err.Clear    'clear the error object
  2273. On Error Resume Next
  2274.     'Cleanup
  2275.    
  2276. End Function
  2277.  
  2278. ' Module:       modRegistry.bas
  2279. ' Function:     SReg_Set_StringValue
  2280. ' Type:         Public
  2281. ' By:           JA
  2282. ' Desc:         Adds a string to the registry
  2283. ' Inputs:       enmClassKey             selected registry key
  2284. '               strSectionKey           registry path to find value
  2285. '               strValueKey             registry key to add value to
  2286. '               strSectionValue         registry section value (to add)
  2287. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  2288. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  2289. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  2290. ' Returns:
  2291. '               -1      Internal error occured
  2292. '                0      string not added
  2293. '                1      string added successfully
  2294. ' Note:         None
  2295. ' Example:
  2296. '   Dim lngRetVal As Long
  2297. '   lngRetVal = SReg_Set_StringValue(HKEY_LOCAL_MACHINE, "Software\Microfot\Windows\CurrentVersion", "Run", "MyStartupApp.exe", "", True, True)
  2298. Public Function SReg_Set_StringValue(enmClassKey As ERegistryClassConstants, _
  2299.                                      strSectionKey As String, _
  2300.                                      strValueKey As String, _
  2301.                                      strSectionValue As String, _
  2302.                                      Optional strMsgBoxTitle As String, _
  2303.                                      Optional blnErr_ShowFriendly As Boolean, _
  2304.                                      Optional blnErr_ShowCritical As Boolean _
  2305.                                     ) As Long
  2306. On Error GoTo err_SReg_Set_StringValue    'initiate error handler
  2307.    SReg_Set_StringValue = 0    'set default return
  2308.    
  2309.     Dim cRegistry       As New clsRegistry
  2310.    
  2311.     If Left(strSectionKey, 1) = "\" Then strSectionKey = Right(strSectionKey, Len(strSectionKey) - 1)
  2312.     If Right(strSectionKey, 1) = "\" Then strSectionKey = Left(strSectionKey, Len(strSectionKey) - 1)
  2313.    
  2314.     strValueKey = Trim(strValueKey)
  2315.     strSectionValue = Trim(strSectionValue)
  2316.    
  2317.     With cRegistry
  2318.         .ClassKey = enmClassKey
  2319.         .SectionKey = strSectionKey
  2320.         .ValueType = REG_SZ
  2321.         .ValueKey = strValueKey
  2322.         .Value = strSectionValue
  2323.     End With
  2324.    
  2325.     SReg_Set_StringValue = 1
  2326.     Set cRegistry = Nothing
  2327.     Exit Function
  2328. err_SReg_Set_StringValue:    'error handler
  2329.    SReg_Set_StringValue = -1    'set internal error return
  2330.    'send message to immediate window
  2331.    Debug.Print Now & " | Function: & SReg_Set_StringValue & | Error: #" & _
  2332.                 Err.Number & vbTab & Err.Description
  2333.     'if we want to show critical messages to the user
  2334.    If blnErr_ShowCritical = True Then
  2335.         'notify the user
  2336.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2337.                vbCrLf & vbCrLf & Now, _
  2338.                vbOKOnly + vbCritical, _
  2339.                strMsgBoxTitle & " [Function: SReg_Set_StringValue" & "]"
  2340.     End If
  2341.     Err.Clear    'clear the error object
  2342. On Error Resume Next
  2343.     'Cleanup
  2344.    
  2345. End Function
  2346.  
  2347. ' Module:       modRegistry.bas
  2348. ' Function:     SReg_Xtr_AssociateFileType
  2349. ' Type:         Public
  2350. ' By:           JA
  2351. ' Desc:         Associates a program with a file type
  2352. ' Inputs:       strExePath              Path to the executable (including executable)
  2353. '               strClassName            Class name of the exe
  2354. '               strClassDesc            Description of the exe's class type
  2355. '               strFileExtension        the extension to associate the program with
  2356. '               strOpenMenuText         Optional Value: default is "&Open...":      Menu text for open
  2357. '               blnSupportPrinting      Optional Value: default is False:           Do you want to have an 'Print' option in the menu?
  2358. '               strPrintMenuText        Optional Value: default is "&Print...":     Menu text for printing
  2359. '               blnSupportNew           Optional Value: default is False:           Do you want to have an 'New' option in the menu?
  2360. '               strNewMenuText          Optional Value: default is "&New...":       Menu text for making a new (empty) file
  2361. '               blnSupportInstall       Optional Value: default is False:           Do you want to have an 'Install' option in the menu?
  2362. '               strInstallMenuText      Optional Value: default is "&Install...":   Menu text for installing the file
  2363. '               strDefaultIconIndex     Optional Value: default is -1:              Icon index to use with the file
  2364. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  2365. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  2366. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  2367. ' Returns:
  2368. '               -1      Internal error occured
  2369. '                0      Association not made
  2370. '                1      Association made
  2371. ' Note:         None
  2372. ' Example:
  2373. '   Dim lngRetVal As Long
  2374. '    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)
  2375. Public Function SReg_Xtr_AssociateFileType(strExePath As String, _
  2376.                                            strClassName As String, _
  2377.                                            strClassDesc As String, _
  2378.                                            strFileExtension As String, _
  2379.                                            Optional strOpenMenuText As String = "&Open...", _
  2380.                                            Optional blnSupportPrinting As Boolean = False, _
  2381.                                            Optional strPrintMenuText As String = "&Print...", _
  2382.                                            Optional blnSupportNew As Boolean = False, _
  2383.                                            Optional strNewMenuText As String = "&New...", _
  2384.                                            Optional blnSupportInstall As Boolean = False, _
  2385.                                            Optional strInstallMenuText As String = "&Install...", _
  2386.                                            Optional strDefaultIconIndex As String = -1, _
  2387.                                            Optional strMsgBoxTitle As String, _
  2388.                                            Optional blnErr_ShowFriendly As Boolean, _
  2389.                                            Optional blnErr_ShowCritical As Boolean _
  2390.                                           ) As Long
  2391. On Error GoTo err_SReg_Xtr_AssociateFileType    'initiate error handler
  2392.    SReg_Xtr_AssociateFileType = 0    'set default return
  2393.    
  2394.     Dim cRegistry       As New clsRegistry
  2395.    
  2396.     With cRegistry
  2397.         .CreateEXEAssociation strExePath, _
  2398.                               strClassName, _
  2399.                               strClassDesc, _
  2400.                               strFileExtension, _
  2401.                               strOpenMenuText, _
  2402.                               blnSupportPrinting, _
  2403.                               strPrintMenuText, _
  2404.                               blnSupportNew, _
  2405.                               strNewMenuText, _
  2406.                               blnSupportInstall, _
  2407.                               strInstallMenuText, _
  2408.                               strDefaultIconIndex
  2409.     End With
  2410.    
  2411.     SReg_Xtr_AssociateFileType = 1
  2412.     Exit Function
  2413. err_SReg_Xtr_AssociateFileType:    'error handler
  2414.    SReg_Xtr_AssociateFileType = -1    'set internal error return
  2415.    'send message to immediate window
  2416.    Debug.Print Now & " | Function: & SReg_Xtr_AssociateFileType & | Error: #" & _
  2417.                 Err.Number & vbTab & Err.Description
  2418.     'if we want to show critical messages to the user
  2419.    If blnErr_ShowCritical = True Then
  2420.         'notify the user
  2421.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2422.                vbCrLf & vbCrLf & Now, _
  2423.                vbOKOnly + vbCritical, _
  2424.                strMsgBoxTitle & " [Function: SReg_Xtr_AssociateFileType" & "]"
  2425.     End If
  2426.     Err.Clear    'clear the error object
  2427. On Error Resume Next
  2428.     'Cleanup
  2429.    
  2430. End Function
  2431.  
  2432. ' Module:       modRegistry.bas
  2433. ' Function:     SReg_Xtr_GetDefaultApp
  2434. ' Type:         Public
  2435. ' By:           JA
  2436. ' Desc:         Returns the defualt application to launch a specified file
  2437. ' Inputs:       strFileName             file name (can include path) to find default program for
  2438. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  2439. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  2440. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  2441. ' Note:         None
  2442. ' Example:
  2443. '   Dim strRetVal As String
  2444. '   strRetVal = SReg_Xtr_GetDefaultApp("C:\Windows\ReadMe.txt", "", True, True)
  2445. '   -OR-
  2446. '   strRetVal = SReg_Xtr_GetDefaultApp("C:\Windows\ReadMe.txt")
  2447. '   strRetVal will now contain: "C:\WINNT\system32\NOTEPAD.EXE %1
  2448. Public Function SReg_Xtr_GetDefaultApp(strFileName As String, _
  2449.                                        Optional strMsgBoxTitle As String, _
  2450.                                        Optional blnErr_ShowFriendly As Boolean, _
  2451.                                        Optional blnErr_ShowCritical As Boolean _
  2452.                                       ) As String
  2453. On Error GoTo err_SReg_Xtr_GetDefaultApp    'initiate error handler
  2454.    SReg_Xtr_GetDefaultApp = vbNullString    'set default return
  2455.    
  2456.     Dim strFileExt          As String
  2457.     Dim strFileType         As String
  2458.     Dim strCurrChar         As String
  2459.     Dim intCharPos          As String
  2460.     Dim strTypeName         As String
  2461.     Dim strDefAction        As String
  2462.    
  2463.     intCharPos = Len(strFileName)
  2464.     Do Until strCurrChar = "."
  2465.         strCurrChar = Mid(strFileName, intCharPos, 1)
  2466.         strFileExt = strCurrChar & strFileExt
  2467.         If strCurrChar = "." Then Exit Do
  2468.         intCharPos = intCharPos - 1
  2469.     Loop
  2470.    
  2471.     strTypeName = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strFileExt, "")
  2472.     strFileType = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName, "")
  2473.     strDefAction = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName & "\shell", "")
  2474.     SReg_Xtr_GetDefaultApp = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName & "\shell\" & strDefAction & "\command", "")
  2475.    
  2476.     SReg_Xtr_GetDefaultApp = Trim(SReg_Xtr_GetDefaultApp)
  2477.    
  2478.     If Len(Trim(SReg_Xtr_GetDefaultApp)) < 1 Then
  2479.         SReg_Xtr_GetDefaultApp = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName & "\shell\open\command", "")
  2480.         If Len(Trim(SReg_Xtr_GetDefaultApp)) < 1 Then SReg_Xtr_GetDefaultApp = "Unknown"
  2481.     End If
  2482.    
  2483.     Exit Function
  2484. err_SReg_Xtr_GetDefaultApp:    'error handler
  2485.    SReg_Xtr_GetDefaultApp = vbNullString    'set internal error return
  2486.    'send message to immediate window
  2487.    Debug.Print Now & " | Function: & SReg_Xtr_GetDefaultApp & | Error: #" & _
  2488.                 Err.Number & vbTab & Err.Description
  2489.     'if we want to show critical messages to the user
  2490.    If blnErr_ShowCritical = True Then
  2491.         'notify the user
  2492.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2493.                vbCrLf & vbCrLf & Now, _
  2494.                vbOKOnly + vbCritical, _
  2495.                strMsgBoxTitle & " [Function: SReg_Xtr_GetDefaultApp" & "]"
  2496.     End If
  2497.     Err.Clear    'clear the error object
  2498. On Error Resume Next
  2499.     'Cleanup
  2500.    
  2501. End Function
  2502.  
  2503. ' Module:       modRegistry.bas
  2504. ' Function:     SReg_Xtr_GetFileType
  2505. ' Type:         Public
  2506. ' By:           JA
  2507. ' Desc:         Descriptive File Type
  2508. ' Inputs:       strFileName             file name (can include path) to find file type name from
  2509. '               strMsgBoxTitle          Optional Value: Caption of the error message box's
  2510. '               blnErr_ShowFriendly     Optional Value: if 'True' then will display friendly errors
  2511. '               blnErr_ShowCritical     Optional Value: if 'True' then will display critical errors
  2512. ' Note:         None
  2513. ' Example:
  2514. '   Dim strRetVal As String
  2515. '   strRetVal = SReg_Xtr_GetFileType("C:\Windows\ReadMe.txt", "", True, True)
  2516. '   -OR-
  2517. '   strRetVal = SReg_Xtr_GetFileType("C:\Windows\ReadMe.txt")
  2518. '   strRetVal will now contain: "Text Document"
  2519. Public Function SReg_Xtr_GetFileType(strFileName As String, _
  2520.                                      Optional strMsgBoxTitle As String, _
  2521.                                      Optional blnErr_ShowFriendly As Boolean, _
  2522.                                      Optional blnErr_ShowCritical As Boolean _
  2523.                                     ) As String
  2524. On Error GoTo err_SReg_Xtr_GetFileType    'initiate error handler
  2525.    SReg_Xtr_GetFileType = vbNullString    'set default return
  2526.    
  2527.     Dim strFileExt      As String
  2528.     Dim strFileType     As String
  2529.     Dim strCurrChar     As String
  2530.     Dim intCharPos      As String
  2531.     Dim strTypeName     As String
  2532.    
  2533.     intCharPos = Len(strFileName)
  2534.     Do Until strCurrChar = "."
  2535.         strCurrChar = Mid(strFileName, intCharPos, 1)
  2536.         strFileExt = strCurrChar & strFileExt
  2537.         If strCurrChar = "." Then Exit Do
  2538.         intCharPos = intCharPos - 1
  2539.     Loop
  2540.    
  2541.     strTypeName = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strFileExt, "")
  2542.    
  2543.     SReg_Xtr_GetFileType = SReg_Get_StringValue(HKEY_CLASSES_ROOT, strTypeName, "")
  2544.    
  2545.     If Len(Trim(SReg_Xtr_GetFileType)) < 1 Then SReg_Xtr_GetFileType = "Unknown"
  2546.    
  2547.     Exit Function
  2548. err_SReg_Xtr_GetFileType:    'error handler
  2549.    SReg_Xtr_GetFileType = vbNullString    'set internal error return
  2550.    'send message to immediate window
  2551.    Debug.Print Now & " | Function: & SReg_Xtr_GetFileType & | Error: #" & _
  2552.                 Err.Number & vbTab & Err.Description
  2553.     'if we want to show critical messages to the user
  2554.    If blnErr_ShowCritical = True Then
  2555.         'notify the user
  2556.        MsgBox "Error: #" & Err.Number & vbTab & Err.Description & _
  2557.                vbCrLf & vbCrLf & Now, _
  2558.                vbOKOnly + vbCritical, _
  2559.                strMsgBoxTitle & " [Function: SReg_Xtr_GetFileType" & "]"
  2560.     End If
  2561.     Err.Clear    'clear the error object
  2562. On Error Resume Next
  2563.     'Cleanup
  2564.    
  2565. End Function
  2566.  
  2567. '__________________________________________________________
  2568. 'To Get All The SubKeys of a Key
  2569. 'Getting all the values with a key is achieved in a similar way,
  2570. 'except you use EnumerateValues instead of EnumerateSections
  2571. '
  2572. '    Dim c As New clsRegistry
  2573. '    Dim sKeys() As String, iKeyCount As Long
  2574. '
  2575. '    With c
  2576. '        .ClassKey = HKEY_LOCAL_MACHINE
  2577. '        .SectionKey = "Software"
  2578. '        .EnumerateSections(sKeys(), iKeyCount)
  2579. '        For iKey = 1 To iKeyCount
  2580. '            Debug.Print sKeys(iKey)
  2581. '        Next iKey
  2582. '    End With
  2583. '
  2584. '__________________________________________________________
  2585. 'To Read BINARY values from the registry
  2586. 'Binary values are returned as a variant of type byte array.
  2587. 'This code demonstrates how to format the returned value into
  2588. 'a string of hexadecimal values, similar to the display
  2589. 'provided in RegEdit:
  2590. '
  2591. '    Dim cR As New clsRegistry
  2592. '    Dim iByte As Long
  2593. '    Dim vR As Variant
  2594. '
  2595. '    With cR
  2596. '        .ClassKey = HKEY_CURRENT_USER
  2597. '        .SectionKey = "Control Panel\Appearance"
  2598. '        .ValueKey = "CustomColors"
  2599. '        vR = .Value
  2600. '
  2601. '        If .ValueType = REG_BINARY Then
  2602. '        ' Read through the byte array and output it as a series of hex values:
  2603. '        For iByte = LBound(vR) To UBound(vR)
  2604. '            sOut = sOut & "&H"
  2605. '            If (iByte < &H10) Then
  2606. '                sOut = sOut & "0"
  2607. '            End If
  2608. '            sOut = sOut & Hex$(vR(iByte)) & " "
  2609. '            Next iByte
  2610. '        Else
  2611. '            sOut = vR
  2612. '        End If
  2613. '
  2614. '        Debug.Print sOut
  2615. '    End With
  2616. '
  2617. '__________________________________________________________
  2618. 'To Set BINARY values to the registry
  2619. 'Similarly, to store binary values in the registry, clsRegistry.cls
  2620. 'expects a byte array of the binary values you wish to store.
  2621. 'This example (rather uselessly!) stores all the Red, Green,
  2622. 'Blue values of each of VB's QBColors into a binary array:
  2623. '
  2624. '    Dim cR As New clsRegistry
  2625. '    Dim i As Long
  2626. '    Dim lC As Long
  2627. '    Dim bR As Byte
  2628. '    Dim bG As Byte
  2629. '    Dim bB As Byte
  2630. '    Dim bOut() As Byte
  2631. '
  2632. '    ' Create a binary array containing all the Red,Green,Blue values of the QBColors:
  2633. '    ReDim bOut(0 To 15 * 3 - 1) As Byte
  2634. '    For i = 1 To 15
  2635. '        ' Get the Red, Green, Blue for the QBColor at index i:
  2636. '        lC = QBColor(i)
  2637. '        bR = (lC And &HFF&)
  2638. '        bG = ((lC And &HFF00&) \ &H100&)
  2639. '        bB = ((lC And &HFF0000) \ &H10000)
  2640. '
  2641. '        ' Add Red, Green, Blue to the byte array to store:
  2642. '        bOut((i - 1) * 3) = bR
  2643. '        bOut((i - 1) * 3 + 1) = bG
  2644. '        bOut((i - 1) * 3 + 2) = bB
  2645. '    Next i
  2646. '
  2647. '    ' Store it:
  2648. '    With cR
  2649. '        .ClassKey = HKEY_CURRENT_USER
  2650. '        .SectionKey = "software\Company Name\Test\clsRegistry\Binary Test"
  2651. '        .ValueKey = "QBColors"
  2652. '        .ValueType = REG_BINARY
  2653. '        .Value = bOut()
  2654. '    End With
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement