?? common.bas
字號:
Attribute VB_Name = "basCommon"
Option Explicit
Option Compare Text
'
' Global Constants
'
Global Const gstrSEP_DIR$ = "\" ' Directory separator character
Global Const gstrSEP_AMPERSAND$ = "@"
Global Const gstrSEP_REGKEY$ = "\" ' Registration key separator character.
Global Const gstrSEP_DRIVE$ = ":" ' Driver separater character, e.g., C:\
Global Const gstrSEP_DIRALT$ = "/" ' Alternate directory separator character
Global Const gstrSEP_EXT$ = "." ' Filename extension separator character
Global Const gstrSEP_PROGID = "."
Global Const gstrSEP_FILE$ = "|" ' Use the character for delimiting filename lists because it is not a valid character in a filename.
Global Const gstrSEP_LIST = "|"
Global Const gstrSEP_URL$ = "://" ' Separator that follows HPPT in URL address
Global Const gstrSEP_URLDIR$ = "/" ' Separator for dividing directories in URL addresses.
Global Const gstrUNC$ = "\\" 'UNC specifier \\
Global Const gstrCOLON$ = ":"
Global Const gstrSwitchPrefix1 = "-"
Global Const gstrSwitchPrefix2 = "/"
Global Const gstrCOMMA$ = ","
Global Const gstrDECIMAL$ = "."
Global Const gstrQUOTE$ = """"
Global Const gstrCCOMMENT$ = "//" ' Comment specifier used in C, etc.
Global Const gstrASSIGN$ = "="
Global Const gstrINI_PROTOCOL = "Protocol"
Global Const gstrREMOTEAUTO = "RA"
Global Const gstrDCOM = "DCOM"
Global Const gintMAX_SIZE% = 255 'Maximum buffer size
Global Const gintMAX_PATH_LEN% = 260 ' Maximum allowed path length including path, filename,
' and command line arguments for NT (Intel) and Win95.
Global Const gintMAX_GROUPNAME_LEN% = 30 ' Maximum length that we allow for an NT 3.51 group name.
Global Const gintMIN_BUTTONWIDTH% = 1200
Global Const gsngBUTTON_BORDER! = 1.4
Global Const intDRIVE_REMOVABLE% = 2 'Constants for GetDriveType
Global Const intDRIVE_FIXED% = 3
Global Const intDRIVE_REMOTE% = 4
Global Const intDRIVE_CDROM% = 5
Global Const intDRIVE_RAMDISK% = 6
Global Const gintNOVERINFO% = 32767 'flag indicating no version info
'File names
Global Const gstrFILE_SETUP$ = "SETUP.LST" 'Name of setup information file
Global Const gstrTEMP_DIR$ = "TEMP"
Global Const gstrTMP_DIR$ = "TMP"
'Share type macros for files
Global Const mstrPRIVATEFILE = ""
Global Const mstrSHAREDFILE = "$(Shared)"
'INI File keys
Global Const gstrINI_FILES$ = "Setup1 Files" 'default section to install
Global Const gstrINI_SETUP$ = "Setup"
Global Const gstrINI_COLOR$ = "Color"
Global Const gstrINI_BOOT$ = "Bootstrap"
Global Const gstrINI_APPNAME$ = "Title"
Global Const gstrINI_CABS$ = "Cabs"
Global Const gstrINI_APPDIR$ = "DefaultDir"
Global Const gstrINI_APPEXE$ = "AppExe"
Global Const gstrINI_APPTOUNINSTALL = "AppToUninstall"
Global Const gstrINI_APPPATH$ = "AppPath"
Global Const gstrINI_FORCEUSEDEFDEST = "ForceUseDefDir"
Global Const gstrINI_DEFGROUP$ = "DefProgramGroup"
Global Const gstrINI_CABNAME$ = "CabFile"
Global Const gsPRIVATE As String = "PrivateGroup"
Global Const gstrEXT_DEP$ = "DEP"
'Setup information file macros
Global Const gstrAPPDEST$ = "$(AppPath)"
Global Const gstrWINDEST$ = "$(WinPath)"
Global Const gstrFONTDEST$ = "$(Font)"
Global Const gstrWINSYSDEST$ = "$(WinSysPath)"
Global Const gstrWINSYSDESTSYSFILE$ = "$(WinSysPathSysFile)"
Global Const gstrPROGRAMFILES$ = "$(ProgramFiles)"
Global Const gstrCOMMONFILES$ = "$(CommonFiles)"
Global Const gstrCOMMONFILESSYS$ = "$(CommonFilesSys)"
Global Const gstrDAODEST$ = "$(MSDAOPath)"
Global Const gstrDONOTINSTALL$ = "$(DoNotInstall)"
Global Const gsZERO As String = "0"
'Mouse Pointer Constants
Global Const gintMOUSE_DEFAULT% = 0
'MsgError() Constants
Global Const MSGERR_ERROR = 1
Global Const MSGERR_WARNING = 2
'Shell Constants
Global Const NORMAL_PRIORITY_CLASS As Long = &H20&
Global Const INFINITE As Long = -1&
Global Const STATUS_WAIT_0 As Long = &H0
Global Const STATUS_ABANDONED_WAIT_0 As Long = &H80
Global Const STATUS_USER_APC As Long = &HC0
Global Const STATUS_TIMEOUT As Long = &H102
Global Const STATUS_PENDING As Long = &H103
Global Const WAIT_FAILED As Long = &HFFFFFFFF
Global Const WAIT_OBJECT_0 As Long = STATUS_WAIT_0
Global Const WAIT_TIMEOUT As Long = STATUS_TIMEOUT
Global Const WAIT_ABANDONED As Long = STATUS_ABANDONED_WAIT_0
Global Const WAIT_ABANDONED_0 As Long = STATUS_ABANDONED_WAIT_0
Global Const WAIT_IO_COMPLETION As Long = STATUS_USER_APC
Global Const STILL_ACTIVE As Long = STATUS_PENDING
'GetLocaleInfo constants
Global Const LOCALE_FONTSIGNATURE = &H58& ' font signature
Global Const LOCALE_SLANGUAGE = &H2
Global Const LOCALE_SABBREVLANGNAME = &H3
Global Const TCI_SRCFONTSIG = 3
Global Const LANG_CHINESE = &H4
Global Const SUBLANG_CHINESE_TRADITIONAL = &H1 ' Chinese (Taiwan)
Global Const SUBLANG_CHINESE_SIMPLIFIED = &H2 ' Chinese (PR China)
Global Const CHARSET_CHINESESIMPLIFIED = 134
Global Const CHARSET_CHINESEBIG5 = 136
Global Const LANG_JAPANESE = &H11
Global Const CHARSET_SHIFTJIS = 128
Global Const LANG_KOREAN = &H12
Global Const SUBLANG_KOREAN = &H1 ' Korean (Extended Wansung)
Global Const SUBLANG_KOREAN_JOHAB = &H2 ' Korean (Johab)
Global Const CHARSET_HANGEUL = 129
Public Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
nReserved1 As Integer
nReserved2 As Integer
szPathName As String * 256
End Type
Type VERINFO 'Version FIXEDFILEINFO
'There is data in the following two dwords, but it is for Windows internal
' use and we should ignore it
Ignore(1 To 8) As Byte
'Signature As Long
'StrucVersion As Long
FileVerPart2 As Integer
FileVerPart1 As Integer
FileVerPart4 As Integer
FileVerPart3 As Integer
ProductVerPart2 As Integer
ProductVerPart1 As Integer
ProductVerPart4 As Integer
ProductVerPart3 As Integer
FileFlagsMask As Long 'VersionFileFlags
FileFlags As Long 'VersionFileFlags
FileOS As Long 'VersionOperatingSystemTypes
FileType As Long
FileSubtype As Long 'VersionFileSubTypes
'I've never seen any data in the following two dwords, so I'll ignore them
Ignored(1 To 8) As Byte 'DateHighPart As Long, DateLowPart As Long
End Type
Type PROTOCOL
strName As String
strFriendlyName As String
End Type
Type OSVERSIONINFO 'for GetVersionEx API call
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Type LOCALESIGNATURE
lsUsb(3) As Long
lsCsbDefault(1) As Long
lsCsbSupported(1) As Long
End Type
Type FONTSIGNATURE
fsUsb(3) As Long
fsCsb(1) As Long
End Type
Type CHARSETINFO
ciCharset As Long
ciACP As Long
fs As FONTSIGNATURE
End Type
Global Const OF_EXIST& = &H4000&
Global Const OF_SEARCH& = &H400&
Global Const HFILE_ERROR% = -1
'
' Global variables used for silent and SMS installation
'
Public gfSilent As Boolean ' Whether or not we are doing a silent install
Public gstrSilentLog As String ' filename for output during silent install.
Public gfSMS As Boolean ' Whether or not we are doing an SMS silent install
Public gstrMIFFile As String ' status output file for SMS
Public gfSMSStatus As Boolean ' status of SMS installation
Public gstrSMSDescription As String ' description string written to MIF file for SMS installation
Public gfNoUserInput As Boolean ' True if either gfSMS or gfSilent is True
Public gfDontLogSMS As Boolean ' Prevents MsgFunc from being logged to SMS (e.g., for confirmation messasges)
Global Const MAX_SMS_DESCRIP = 255 ' SMS does not allow description strings longer than 255 chars.
'Variables for caching font values
Private m_sFont As String ' the cached name of the font
Private m_nFont As Integer ' the cached size of the font
Private m_nCharset As Integer ' the cached charset of the font
Global Const gsSTARTMENUKEY As String = "$(Start Menu)"
Global Const gsPROGMENUKEY As String = "$(Programs)"
Global Const gsSTART As String = "StartIn"
Global Const gsPARENT As String = "Parent"
'
'List of available protocols
'
Global gProtocol() As PROTOCOL
Global gcProtocols As Integer
'
' AXDist.exe and wint351.exe needed. These are self extracting exes
' that install other files not installed by setup1.
'
Public gfAXDist As Boolean
Global Const gstrFILE_AXDIST = "AXDIST.EXE"
Public gstrAXDISTInstallPath As String
Public gfAXDistChecked As Boolean
Public gfMDag As Boolean
Global Const gstrFILE_MDAG = "mdac_typ.exe"
Global Const gstrFILE_MDAGARGS = " /q:a /c:""setup.exe /QN1"""
Public gstrMDagInstallPath As String
Public gfWINt351 As Boolean
Global Const gstrFILE_WINT351 = "WINt351.EXE"
Public gstrWINt351InstallPath As String
Public gfWINt351Checked As Boolean
'
'API/DLL Declarations for 32 bit SetupToolkit
'
Declare Function SetTime Lib "vb6stkit.dll" (ByVal strFileGetTime As String, ByVal strFileSetTime As String) As Integer
Declare Function DLLSelfRegister Lib "vb6stkit.dll" (ByVal lpDllName As String) As Integer
Declare Function RegisterTLB Lib "vb6stkit.dll" (ByVal lpTLBName As String) As Integer
Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long
Declare Function OSfRemoveShellLink Lib "vb6stkit.dll" Alias "fRemoveShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String) As Long
Declare Function GetSystemDefaultLCID Lib "Kernel32" () As Long
Declare Function GetLocaleInfoLS Lib "Kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, lpLCData As LOCALESIGNATURE, ByVal cchData As Long) As Long
Declare Function TranslateCharsetInfo Lib "gdi32" (lpSrc As Long, lpcs As CHARSETINFO, ByVal dwFlags As Long) As Long
Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long)
Declare Function WaitForSingleObject Lib "Kernel32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
Declare Function InputIdle Lib "user32" Alias "WaitForInputIdle" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
Declare Function CreateProcessA Lib "Kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Declare Function CloseHandle Lib "Kernel32" (ByVal hObject As Long) As Long
Declare Function GetDiskFreeSpace Lib "Kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
Declare Function OpenFile Lib "Kernel32" (ByVal lpFilename As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Declare Function GetFullPathName Lib "Kernel32" Alias "GetFullPathNameA" (ByVal lpFilename As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal lSize As Long, ByVal lpFilename As String) As Long
Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As Any, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFilename As String) As Long
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
Declare Function GetPrivateProfileSectionNames Lib "Kernel32" Alias "GetPrivateProfileSectionNamesA" (ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFilename As String) As Long
Declare Function GetWindowsDirectory Lib "Kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetSystemDirectory Lib "Kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetDriveType32 Lib "Kernel32" Alias "GetDriveTypeA" (ByVal strWhichDrive As String) As Long
Declare Function GetTempFilename32 Lib "Kernel32" Alias "GetTempFileNameA" (ByVal strWhichDrive As String, ByVal lpPrefixString As String, ByVal wUnique As Integer, ByVal lpTempFilename As String) As Long
Declare Function GetTempPath Lib "Kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Global Const LB_FINDSTRINGEXACT = &H1A2
Global Const LB_ERR = (-1)
Declare Function GetUserDefaultLCID Lib "Kernel32" () As Long
Declare Sub GetLocaleInfoA Lib "Kernel32" (ByVal lLCID As Long, ByVal lLCTYPE As Long, ByVal strLCData As String, ByVal lDataLen As Long)
Declare Function VerInstallFile Lib "version.dll" Alias "VerInstallFileA" (ByVal Flags&, ByVal SrcName$, ByVal DestName$, ByVal SrcDir$, ByVal DestDir$, ByVal CurrDir As Any, ByVal TmpName$, lpTmpFileLen&) As Long
Declare Function GetFileVersionInfoSize Lib "version.dll" Alias "GetFileVersionInfoSizeA" (ByVal sFile As String, lpLen) As Long
Declare Function GetFileVersionInfo Lib "version.dll" Alias "GetFileVersionInfoA" (ByVal sFile As String, ByVal lpIgnored As Long, ByVal lpSize As Long, ByVal lpBuf As Long) As Long
Declare Function VerQueryValue Lib "version.dll" Alias "VerQueryValueA" (ByVal lpBuf As Long, ByVal szReceive As String, lpBufPtr As Long, lLen As Long) As Long
Declare Function OSGetShortPathName Lib "Kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Declare Function GetVersionEx Lib "Kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
' Reboot system code
Public Const EWX_REBOOT = 2
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
'----------------------------------------------------------
' FUNCTION: GetWinPlatform
' Get the current windows platform.
' ---------------------------------------------------------
Public Function GetWinPlatform() As Long
Dim osvi As OSVERSIONINFO
Dim strCSDVersion As String
osvi.dwOSVersionInfoSize = Len(osvi)
If GetVersionEx(osvi) = 0 Then
Exit Function
End If
GetWinPlatform = osvi.dwPlatformId
End Function
'-----------------------------------------------------------
' SUB: AddDirSep
' Add a trailing directory path separator (back slash) to the
' end of a pathname unless one already exists
'
' IN/OUT: [strPathName] - path to add separator to
'-----------------------------------------------------------
'
Sub AddDirSep(strPathName As String)
If Right(Trim(strPathName), Len(gstrSEP_URLDIR)) <> gstrSEP_URLDIR And _
Right(Trim(strPathName), Len(gstrSEP_DIR)) <> gstrSEP_DIR Then
strPathName = RTrim$(strPathName) & gstrSEP_DIR
End If
End Sub
'-----------------------------------------------------------
' SUB: AddURLDirSep
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -