📄 ospath.bas
字号:
Attribute VB_Name = "OSPath"
Public Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Const MAX_PATH = 260
Public Function GetTEMPfolder(Optional ByVal showlong As Boolean = True)
Dim longname As String, shortname As String
shortname = Space(256)
GetTempPath Len(shortname), shortname
longname = Space(1024)
GetLongPathName shortname, longname, Len(longname)
GetTEMPfolder = IIf(showlong = True, longname, shortname)
GetTEMPfolder = Trim(GetTEMPfolder)
GetTEMPfolder = Replace(GetTEMPfolder, Chr(0), "")
End Function
Public Function GetWinPath()
Dim strFolder As String
Dim lngResult As String
strFolder = String(MAX_PATH, 0)
lngResult = GetWindowsDirectory(strFolder, MAX_PATH)
If lngResult <> 0 Then
GetWinPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
Else
GetWinPath = ""
End If
End Function
Public Function GetSystemPath()
Dim strFolder As String
Dim lngResult As String
strFolder = String(MAX_PATH, 0)
lngResult = GetSystemDirectory(strFolder, MAX_PATH)
If lngResult <> 0 Then
GetSystemPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
Else
GetSystemPath = ""
End If
End Function
Public Sub delay(ByVal n As Single)
Dim tm1 As Single, tm2 As Single
tm1 = Timer
Do
tm2 = Timer
If tm2 < tm1 Then tm2 = tm2 + 86400
If tm2 - tm1 > n Then Exit Do
DoEvents
Loop
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -