Attribute VB_Name = "Global"
Option Explicit

'Constant
Public Const MAX_PJ = 256
Public Const MAX_SOCKS = 256
Public Const MAX_QUEUE = 256
Public Const MAX_ERR_QUE = 256
Public Const MAX_GROUP = 256

Public Const QS_NODATA = 0
Public Const QS_READY = 1
Public Const QS_GO = 2
Public Const QS_OK = 3
Public Const QS_NG = 4
Public Const QS_TIMEOUT = 5
Public Const QS_GETSTATUS = 6
Public Const QS_CONNECTING = 7

Public Const ACTION_SET = &H1
Public Const ACTION_GET = &H2
Public Const ACTION_INI = &H3
Public Const ACTION_INC = &H4
Public Const ACTION_DEC = &H5
Public Const ACTION_EXE = &H6

Public Const ERROR_COVERERROR = 1
Public Const ERROR_FANERROR = 2
Public Const ERROR_LAMPERROR = 3
Public Const ERROR_TEMPERROR = 4
Public Const ERROR_AIRFLOWERROR = 5
Public Const ERROR_LAMPTIMEOVER = 6
Public Const ERROR_COOLERROR = 7
Public Const ERROR_FILTERERROR = 8
Public Const ERROR_OTHERERROR = 9
Public Const ERROR_DISCONNECT = 9999

'Structure
Public Type Size
    cx As Long
    cy As Long
End Type

Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Public Type PJ_STATUS
    Power As Integer
    InputSource As Integer
    ErrorStatus As Integer
    LampTime As Integer
    FilterTime As Integer
    Disconnect As Boolean
    Aspect As Integer
    Whisper As Integer
    Mirror As Integer
    Blank As Integer
    Mute As Integer
    Bright As Integer
    Contrast As Integer
    Sharpness As Integer
    Color As Integer
    Tint As Integer
End Type

Public Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

Public Type CONNECTION_RS232C
    PortNo As Integer       'COM Port No
    Settings As String      'Settings
End Type

Public Type CONNECTION_TCP
    IPAddress As String     'IP Address
    PortNo As String        'Port No
    MACAddress As String    'MAC Address
End Type

Public Type CONNECTION_STRUCT
    Kind As Integer         '0:RS-232C, 1:NETWORK
    Serial As CONNECTION_RS232C
    Network As CONNECTION_TCP
End Type

Public Type PJ_INFO
    Name As String          'Projector Name
    ModelName As String     'Model Name
    Connection As CONNECTION_STRUCT
    Status As PJ_STATUS     'PJ Status
End Type

Public Type QueueStruct
    'Index As Integer    'Network:SockNo, Serial:ComNo
    Status As Integer
    Action As Integer
    Operation As Integer
    SendData() As Byte
    SendDataLen As Long
    RecvData() As Byte
    RecvDataLen As Long
End Type

Public Type ALARM_INFO
    SendFlag As Boolean
    AlarmTime As Integer
End Type

Public Type ERROR_INFO_DETAILS
    SendFlag As Boolean
    SendText As String
End Type

Public Type ERROR_INFO
    SendFlag As Boolean
    CoverError As ERROR_INFO_DETAILS
    FanError As ERROR_INFO_DETAILS
    LampError As ERROR_INFO_DETAILS
    TempError As ERROR_INFO_DETAILS
    AirFlowError As ERROR_INFO_DETAILS
    LampTimeOver As ERROR_INFO_DETAILS
    CoolError As ERROR_INFO_DETAILS
    FilterError As ERROR_INFO_DETAILS
    OtherError As ERROR_INFO_DETAILS
    Disconnect As ERROR_INFO_DETAILS
End Type

Public Type MAIL_INFO
    SendFlag As Boolean
    LampAlarm As ALARM_INFO
    FilterAlarm As ALARM_INFO
    ErrorAlarm As ERROR_INFO
    SMTPServer As String
    FromAddress As String
    SendAddress(10) As String
    Subject As String
    FilePath As String
End Type

Public Type MODEL_INFO_DETAILS
    Name As String
    InputNum As Integer
    InputDetails(16) As String
    AspectNum As Integer
    AspectDetails(16) As String
    Network As Integer
    NetworkPort As Integer
End Type

Public Type MODEL_INFO
    ModelNum As Integer
    Model(64) As MODEL_INFO_DETAILS
End Type

'Public Type INPUT_LIST_INFO
'End Type

'Public Type ASPECT_LIST_INFO
'End Type

Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002

Public Const ERROR_SUCCESS = 0&
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const KEY_CREATE_LINK = &H20
Public Const SYNCHRONIZE = &H100000
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))
Public Const REG_OPTION_NON_VOLATILE = 0        ' Key is preserved when system is rebooted
Public Const REG_DWORD = 4                      ' 32-bit number
Public Const REG_SZ = 1                         ' Unicode nul terminated string

Public Const SM_CYMENU = 15
Public Const SM_CXFRAME = 32
Public Const SM_CYFRAME = 33
Public Const SM_CYCAPTION = 4
Public Const SM_CXEDGE = 45
Public Const SM_CYEDGE = 46
Public Const LOGPIXELSX = 88        '  Logical pixels/inch in X
Public Const LOGPIXELSY = 90        '  Logical pixels/inch in Y
Public Const COLOR_HIGHLIGHTTEXT = 14

Public Const ROOT_STATUS = &H10
Public Const ROOT_CONTROL = &H11
Public Const ROOT_SCHEDULE = &H12
Public Const GROUP_STATUS = &H20
Public Const GROUP_CONTROL = &H21
Public Const GROUP_SCHEDULE = &H22
Public Const PROJECTOR_STATUS = &H30
Public Const PROJECTOR_CONTROL = &H31
Public Const PROJECTOR_SCHEDULE = &H32

Public Const OP_LAMP_TIME = &H1090
Public Const OP_FILTER_TIME = &H10A0
Public Const OP_INPUT_SOURCE = &H2000
Public Const OP_MUTE = &H2002
Public Const OP_BRIGHT = &H2003
Public Const OP_CONTRAST = &H2004
Public Const OP_ASPECT = &H2008
Public Const OP_AUTO_ADJUST = &H200A
Public Const OP_SHARPNESS = &H2201
Public Const OP_COLOR = &H2202
Public Const OP_TINT = &H2203
Public Const OP_MIRROR = &H3001
Public Const OP_BLANK = &H3020
Public Const OP_WHISPER = &H3300
Public Const OP_POWER_STATUS = &H6000
Public Const OP_ERROR_STATUS = &H6020

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103

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 RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
'Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Public Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
Public Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) 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         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal szData As String, lpcbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
'Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal szData As String, ByVal cbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hDC As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As Size) As Long
Public Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Public Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
'PJMSend.DLL
Public Declare Function PJMSEND_SendMail Lib "PJMSend" (ByVal szServer As String, ByVal szTo As String, ByVal szForm As String, ByVal szSubject As String, ByVal szBody As String, ByVal szFile As String) As Long

'Variable
Public PJInfo(MAX_PJ) As PJ_INFO
Public bDisconnectFlag(MAX_SOCKS) As Long
Public bAddGroupForm As Boolean
Public bAddPJForm As Boolean
'Public PjKeyNo As Integer
'Public GrKeyNo As Integer
Public TreePJIndex(MAX_PJ * 2) As Integer
Public LogMode As Integer
Public LogFile As LogFileMaker
Public MailLogFile As LogFileMaker
Public m_nPJNum As Integer
Public StartTimerTime As Date
Public Queue(MAX_PJ, MAX_QUEUE) As QueueStruct
Public QueueWP(MAX_PJ) As Integer
Public QueueRP(MAX_PJ) As Integer
Public ErrorQueue(MAX_QUEUE) As String
Public ErrQueWP As Integer
Public ErrQueRP As Integer
Public StatusCheckInterval As Long
Public TcpTimeoutTime As Long
Public CommTimeoutTime As Long
Public PingTimeout As Long
Public MailSending As Boolean
Public MailSendRetryCount As Integer
Public MailSendLastRetryTime
Public LastDate As Date
Public LastTime As Date
Public dtLastDate As Date
Public dtLastTime As Date
Public bMACAddrGetting As Boolean
Public MailInfo As MAIL_INFO
Public TCP_TIMEOUT As Long
Public COMM_TIMEOUT As Long
Public ModelInfo As MODEL_INFO
Public bAddressEdit As Boolean
Public SelectAddressIndex As Integer
Public ErrKindFlag As Integer
Public bMailFormFlag As Boolean
Public bOKFlag As Boolean
Public bErrorFlag As Boolean

Public POWER_GET() As Variant
Public POWER_0() As Variant
Public POWER_1() As Variant
Public INPUT_GET() As Variant
Public INPUT_0() As Variant
Public INPUT_1() As Variant
Public INPUT_2() As Variant
Public INPUT_3() As Variant
Public INPUT_4() As Variant
Public INPUT_5() As Variant
Public INPUT_6() As Variant '##### 2005.01.21 add #####
Public ERROR_GET() As Variant
Public LAMPTIME_GET() As Variant
Public FILTERTIME_GET() As Variant
Public ASPECT_GET() As Variant
Public ASPECT_0() As Variant
Public ASPECT_1() As Variant
Public ASPECT_2() As Variant
Public ASPECT_3() As Variant
Public ASPECT_4() As Variant
Public ASPECT_5() As Variant
Public ASPECT_6() As Variant
Public ASPECT_7() As Variant
Public ASPECT_16() As Variant
Public BRIGHT_GET() As Variant
Public BRIGHT_INC() As Variant
Public BRIGHT_DEC() As Variant
Public CONTRAST_GET() As Variant
Public CONTRAST_INC() As Variant
Public CONTRAST_DEC() As Variant
Public COLOR_GET() As Variant
Public COLOR_INC() As Variant
Public COLOR_DEC() As Variant
Public TINT_GET() As Variant
Public TINT_INC() As Variant
Public TINT_DEC() As Variant
Public SHARPNESS_GET() As Variant
Public SHARPNESS_INC() As Variant
Public SHARPNESS_DEC() As Variant
Public WHISPER_GET() As Variant
Public WHISPER_0() As Variant
Public WHISPER_1() As Variant
Public MIRROR_GET() As Variant
Public MIRROR_0() As Variant
Public MIRROR_1() As Variant
Public MIRROR_2() As Variant
Public MIRROR_3() As Variant
Public MUTE_GET() As Variant
Public MUTE_0() As Variant
Public MUTE_1() As Variant
Public BLANK_GET() As Variant
Public BLANK_0() As Variant
Public BLANK_1() As Variant
Public AUTOADJUST_EXE() As Variant

'##### 2004.12.15 #####
Public LAMPTIME_RESET() As Variant
Public FILTERTIME_RESET() As Variant
'##### 2004.12.15 #####

Public PingFilePath As String
Public ArpFilePath As String
Public MailSendKindFlag As Integer
Public CommTimeoutCount(MAX_PJ) As Integer

'##### 2004.12.16 ######
Public Type SYSTEMTIME
        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
End Type

Public lngLocaleID As Long
Public sTimeFormat As String

Public Const TIME_NOSECONDS = &H2           '  do not use seconds
Public Const DATE_SHORTDATE = &H1           '  use short date picture
Public Const LANG_NEUTRAL = &H0
Public Const SUBLANG_DEFAULT = &H1          '  user default
Public Const LOCALE_STIME = &H1E            '  time separator
Public Const LOCALE_STIMEFORMAT = &H1003    '  time format string
Public Const LOCALE_SSHORTDATE = &H1F       '  short date format string
Public Declare Function GetDateFormat Lib "kernel32" Alias "GetDateFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, lpDate As SYSTEMTIME, ByVal lpFormat As String, lpDateStr As Any, ByVal cchDate As Long) As Long
Public Declare Function GetTimeFormat Lib "kernel32" Alias "GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, lpTime As SYSTEMTIME, ByVal lpFormat As String, lpTimeStr As Any, ByVal cchTime As Long) As Long
Public Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Public Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, lpLCData As Any, ByVal cchData As Long) As Long
'##### 2004.12.16 ######
