Attribute VB_Name = "modMain"
Option Explicit

' Declare statements for all the functions in the Windows API for registry access
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Public Declare Function GetVersion Lib "kernel32" () As Long

'Constant for HKLM
Public Const HKEY_LOCAL_MACHINE = &H80000002

'Constants for flags when dealing with the registry
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_EVENT = &H1
Public Const KEY_NOTIFY = &H10
Public Const READ_CONTROL = &H20000
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))

'Constant for return value of the registry functions
Public Const ERROR_SUCCESS = &H0
Public Const ERROR_MORE_DATA = &HEA

Public Const VERSION_MASK = &H8000000F
Public Const VERSION_WINXP2000 = &H5
Public Const VERSION_WIN98 = &H80000004

'Variables used within the project
Global devNum As Long     'global variable to hold number of devices connected
Global hUSBDevice As Long 'global handle that is set when connected with the CP2101 device
Global Status As Integer  'status, value to set when communicating with the board to determine success
Global Comport As Integer
Global BaudRate As Long
