📄 common.bas
字号:
'-----------------------------------------------------------
'
Sub LogSilentMsg(strMsg As String)
If Not gfSilent Then Exit Sub
Dim fn As Integer
On Error Resume Next
fn = FreeFile
Open gstrSilentLog For Append As fn
Print #fn, strMsg
Close fn
Exit Sub
End Sub
'-----------------------------------------------------------
' FUNCTION: LogSMSMsg
'
' If this is a SMS install, this routine appends
' a message to the gstrSMSDescription string. This
' string will later be written to the SMS status
' file (*.MIF) when the installation completes (success
' or failure).
'
' Note that if gfSMS = False, not message will be logged.
' Therefore, to prevent some messages from being logged
' (e.g., confirmation only messages), temporarily set
' gfSMS = False.
'
' IN: [strMsg] - The message
'
' Normally, this routine is called inlieu of displaying
' a MsgBox and strMsg is the same message that would
' have appeared in the MsgBox
'-----------------------------------------------------------
'
Sub LogSMSMsg(strMsg As String)
If Not gfSMS Then Exit Sub
'
' Append the message. Note that the total
' length cannot be more than 255 characters, so
' truncate anything after that.
'
gstrSMSDescription = Left(gstrSMSDescription & strMsg, MAX_SMS_DESCRIP)
End Sub
'-----------------------------------------------------------
' FUNCTION: MakePathAux
'
' Creates the specified directory path.
'
' No user interaction occurs if an error is encountered.
' If user interaction is desired, use the related
' MakePathAux() function.
'
' IN: [strDirName] - name of the dir path to make
'
' Returns: True if successful, False if error.
'-----------------------------------------------------------
'
Function MakePathAux(ByVal strDirName As String) As Boolean
Dim strPath As String
Dim intOffset As Integer
Dim intAnchor As Integer
Dim strOldPath As String
On Error Resume Next
'
'Add trailing backslash
'
If Right$(strDirName, 1) <> gstrSEP_DIR Then
strDirName = strDirName & gstrSEP_DIR
End If
strOldPath = CurDir$
MakePathAux = False
intAnchor = 0
'
'Loop and make each subdir of the path separately.
'
intOffset = InStr(intAnchor + 1, strDirName, gstrSEP_DIR)
intAnchor = intOffset 'Start with at least one backslash, i.e. "C:\FirstDir"
Do
intOffset = InStr(intAnchor + 1, strDirName, gstrSEP_DIR)
intAnchor = intOffset
If intAnchor > 0 Then
strPath = Left$(strDirName, intOffset - 1)
' Determine if this directory already exists
Err = 0
ChDir strPath
If Err Then
' We must create this directory
Err = 0
#If LOGGING Then
NewAction gstrKEY_CREATEDIR, """" & strPath & """"
#End If
MkDir strPath
#If LOGGING Then
If Err Then
LogError ResolveResString(resMAKEDIR) & " " & strPath
AbortAction
GoTo Done
Else
CommitAction
End If
#End If
End If
End If
Loop Until intAnchor = 0
MakePathAux = True
Done:
ChDir strOldPath
Err = 0
End Function
'-----------------------------------------------------------
' FUNCTION: MsgError
'
' Forces mouse pointer to default, calls VB's MsgBox
' function, and logs this error and (32-bit only)
' writes the message and the user's response to the
' logfile (32-bit only)
'
' IN: [strMsg] - message to display
' [intFlags] - MsgBox function type flags
' [strCaption] - caption to use for message box
' [intLogType] (optional) - The type of logfile entry to make.
' By default, creates an error entry. Use
' the MsgWarning() function to create a warning.
' Valid types as MSGERR_ERROR and MSGERR_WARNING
'
' Returns: Result of MsgBox function
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' FUNCTION: MsgFunc
'
' Forces mouse pointer to default and calls VB's MsgBox
' function. See also MsgError.
'
' IN: [strMsg] - message to display
' [intFlags] - MsgBox function type flags
' [strCaption] - caption to use for message box
' Returns: Result of MsgBox function
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' SUB: SetFormFont
'
' Walks through all controls on specified form and
' sets Font a font chosen according to the system locale
'
' IN: [frm] - Form whose control fonts need to be set.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' SUB: GetFontInfo
'
' Gets the best font to use according the current system's
' locale.
'
' OUT: [sFont] - name of font
' [nFont] - size of font
' [nCharset] - character set of font to use
'-----------------------------------------------------------
'-----------------------------------------------------------
' FUNCTION: StripTerminator
'
' Returns a string without any zero terminator. Typically,
' this was a string returned by a Windows API call.
'
' IN: [strString] - String to remove terminator from
'
' Returns: The value of the string passed in minus any
' terminating zero.
'-----------------------------------------------------------
'
Function StripTerminator(ByVal strString As String) As String
Dim intZeroPos As Integer
intZeroPos = InStr(strString, Chr$(0))
If intZeroPos > 0 Then
StripTerminator = Left$(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function
'-----------------------------------------------------------
' FUNCTION: GetFileVersion
'
' Returns the internal file version number for the specified
' file. This can be different than the 'display' version
' number shown in the File Manager File Properties dialog.
' It is the same number as shown in the VB5 SetupWizard's
' File Details screen. This is the number used by the
' Windows VerInstallFile API when comparing file versions.
'
' IN: [strFilename] - the file whose version # is desired
' [fIsRemoteServerSupportFile] - whether or not this file is
' a remote ActiveX component support file (.VBR)
' (Enterprise edition only). If missing, False is assumed.
'
' Returns: The Version number string if found, otherwise
' vbnullstring
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' FUNCTION: GetFileVerStruct
'
' Gets the file version information into a VERINFO TYPE
' variable
'
' IN: [strFilename] - name of file to get version info for
' [fIsRemoteServerSupportFile] - whether or not this file is
' a remote ActiveX component support file (.VBR)
' (Enterprise edition only). If missing, False is assumed.
' OUT: [sVerInfo] - VERINFO Type to fill with version info
'
' Returns: True if version info found, False otherwise
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' FUNCTION: GetFileDescription
'
' Gets the file description information.
'
' IN: [strFilename] - name of file to get description of.
'
' Returns: Description (vbNullString if not found)
'-----------------------------------------------------------
'
Function GetWindowsSysDir() As String
Dim strBuf As String
strBuf = Space$(gintMAX_SIZE)
'
'Get the system directory and then trim the buffer to the exact length
'returned and add a dir sep (backslash) if the API didn't return one
'
If GetSystemDirectory(strBuf, gintMAX_SIZE) > 0 Then
strBuf = StripTerminator(strBuf)
AddDirSep strBuf
GetWindowsSysDir = strBuf
Else
GetWindowsSysDir = vbNullString
End If
End Function
'-----------------------------------------------------------
' FUNCTION: GetWindowsFontDir
'
' Calls the windows API to get the windows font directory
' and ensures that a trailing dir separator is present
'
' Returns: The windows font directory
'-----------------------------------------------------------
'
'wsDir
'
' Calls the windows API to get the windows directory and
' ensures that a trailing dir separator is present
'
' Returns: The windows directory
'-----------------------------------------------------------
'
Function GetWindowsDir() As String
Dim strBuf As String
strBuf = Space$(gintMAX_SIZE)
'
'Get the windows directory and then trim the buffer to the exact length
'returned and add a dir sep (backslash) if the API didn't return one
'
If GetWindowsDirectory(strBuf, gintMAX_SIZE) > 0 Then
strBuf = StripTerminator$(strBuf)
AddDirSep strBuf
GetWindowsDir = strBuf
Else
GetWindowsDir = vbNullString
End If
End Function
'
Public Function GerDir(st As String)
Dim i
Dim p() As String
p = Split(st, "\")
For i = 0 To UBound(p) - 1
GerDir = GerDir + p(i) + "\"
Next
'If i = 0 Then prjPath = p(0) + "\"
prjPath = prjPat
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -