📄 api.bas
字号:
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
r = ShellExecuteEX(SEI)
End Sub
Sub ClearDocuments()
Call SHAddToRecentDocs(2, vbNullString)
End Sub
Sub AddToDocuments(FileName As String)
Call SHAddToRecentDocs(2, FileName)
End Sub
Sub PhoneCall(Number As String, Name As String)
Dim lRetVal As Long
lRetVal = tapiRequestMakeCall(Trim$(Number), App.Title, Trim$(Name), "")
If lRetVal <> 0 Then
End If
End Sub
Function IsCapsLockOn()
GetKeyboardState kbArray
IsCapsLockOn = kbArray.kbByte(VK_CAPITAL)
End Function
Function IsNumLockOn()
GetKeyboardState kbArray
IsNumLockOn = kbArray.kbByte(VK_NUMLOCK)
End Function
Sub StayOnTop(TheForm As Form)
SetWinOnTop = SetWindowPos(TheForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub
Function IsScrollLockOn()
GetKeyboardState kbArray
IsScrollLockOn = kbArray.kbByte(VK_SCROLL)
End Function
Sub CapsLock(Enabled As Boolean)
GetKeyboardState kbArray
If Enabled = True Then
kbArray.kbByte(VK_CAPITAL) = 1
ElseIf Enabled = False Then
kbArray.kbByte(VK_CAPITAL) = 0
End If
SetKeyboardState kbArray
End Sub
Sub NumLock(Enabled As Boolean)
GetKeyboardState kbArray
If Enabled = True Then
kbArray.kbByte(VK_NUMLOCK) = 1
ElseIf Enabled = False Then
kbArray.kbByte(VK_NUMLOCK) = 0
End If
SetKeyboardState kbArray
End Sub
Sub ScrollLock(Enabled As Boolean)
GetKeyboardState kbArray
If Enabled = True Then
kbArray.kbByte(VK_SCROLL) = 1
ElseIf Enabled = False Then
kbArray.kbByte(VK_SCROLL) = 0
End If
SetKeyboardState kbArray
End Sub
Sub StartScreensaver(Form1 As Form)
Dim result As Long
result = SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
End Sub
Sub Taskbar(visible As Boolean)
Dim Thwnd As Long
Thwnd = FindWindow("Shell_traywnd", "")
If visible = True Then
Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
ElseIf visible = False Then
Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
End If
End Sub
Function MilliToHMS(Milliseconds)
Dim Sec, Min0, Min, Hr
Hr = Fix(Milliseconds / 3600000)
Min0 = Fix(Milliseconds Mod 3600000)
Min = Fix(Min0 / 60000)
Sec = Fix(Min0 Mod 60000)
Sec = Fix(Sec / 1000)
If Len(Sec) = 1 Then
Sec = "0" & Sec
End If
If Len(Min) = 1 Then
Min = "0" & Min
End If
If Len(Hr) = 1 Then
Hr = "0" & Hr
End If
MilliToHMS = Hr & ":" & Min & ":" & Sec
End Function
Function GetTimeOnWindows()
GetTimeOnWindows = MilliToHMS(GetTickCount&)
End Function
Sub Cursor(Enabled As Boolean)
Dim Retcode
For i = 1 To 50000
Retcode = ShowCursor(Enabled)
Next i
End Sub
Sub ShutDownWindows()
T& = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)
End Sub
Sub RestartWindows()
T& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub
Sub LogOffWindows()
T& = ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0)
End Sub
Function IsThereASoundCard()
Dim i As Integer
i = auxGetNumDevs()
If i > 0 Then
IsThereASoundCard = 1
Else
IsThereASoundCard = 0
End If
End Function
Function DriveBytesFree(DriveLetter As Integer)
XDriveInfo
DriveBytesFree = (vararyDriveInfo(DriveLetter, 9))
End Function
Function DriveTotalBytes(DriveLetter As Integer)
XDriveInfo
DriveTotalBytes = (vararyDriveInfo(DriveLetter, 8))
End Function
Function DrivePercentFree(DriveLetter As Integer)
XDriveInfo
On Error Resume Next
DrivePercentFree = (DriveBytesFree(DriveLetter) / DriveTotalBytes(DriveLetter)) * 100
End Function
Function DriveOtherInfo(DriveLetter As Integer, InfoCode)
XDriveInfo
DriveOtherInfo = (vararyDriveInfo(DriveLetter, InfoCode))
End Function
Sub XDriveInfo()
'1 = Is there a drive for this letter
'2 = Drive Letter
'3 = Drive Type 2: Floppy, 3: Disk Fixed 4: Disk Remote
'4 = Sectors
'5 = Bytes / Sector
'6 = Number of free sectors
'7 = Total Clusters
'8 = Total Bytes
'9 = Free Bytes
'10 = Percent of Free Bytes
'11 = Vol Name
Dim ournum As Long, rv As Long, DriveType As Long, c As Long, d As Long
Dim E As Long, F As Long, H As Long, Counter As Integer, CompareTo
Dim tmpDrvLet As String
Dim SectorsPerCluster&, BytesPerSector&, NumberOfFreeClustors&, TotalNumberOfClustors&
Dim BytesFreeas, BytesTotal, FreeBytes, TotalBytes As Variant
Dim dl&, lpVolumeSerialNumber&, lpMaximumComponentLength&, lpFileSystemFlags&
Dim lpVolumeNameBuffer As String, rcDim As String, B As String
Dim G As String, s$, sz&
rv = GetLogicalDrives&()
If rv = 0 Then
Stop
Exit Sub
End If
B = String$(255, 0)
c = 200
G = String$(255, 0)
H = 100
For Counter = 1 To 26
CompareTo = (2 ^ (Counter - 1))
If (rv And CompareTo) <> 0 Then
vararyDriveInfo(Counter, 1) = True
tmpDrvLet = Chr(Counter + 64)
vararyDriveInfo(Counter, 2) = tmpDrvLet
tmpDrvLet = tmpDrvLet & ":\"
DriveType = GetDriveType&(tmpDrvLet)
vararyDriveInfo(Counter, 3) = DriveType
If DriveType = 3 Or DriveType = 4 Then
rc = GetVolumeInformation(A, B, c, d, E, F, G, H)
vararyDriveInfo(Counter, 11) = B
dl& = GetDiskFreeSpace(tmpDrvLet, SectorsPerCluster, BytesPerSector, NumberOfFreeClustors, TotalNumberOfClustors)
vararyDriveInfo(Counter, 4) = Format(SectorsPerCluster, "#,0")
vararyDriveInfo(Counter, 5) = Format(BytesPerSector, "#,0")
vararyDriveInfo(Counter, 6) = Format(NumberOfFreeClustors, "#,0")
vararyDriveInfo(Counter, 7) = Format(TotalNumberOfClustors, "#,0")
TotalBytes = (TotalNumberOfClustors / 100) * (SectorsPerCluster / 100) * (BytesPerSector / 100)
vararyDriveInfo(Counter, 8) = Format(TotalBytes, "#,0")
FreeBytes = (NumberOfFreeClustors / 100) * (SectorsPerCluster / 100) * (BytesPerSector / 100)
vararyDriveInfo(Counter, 9) = Format(FreeBytes, "#,0")
vararyDriveInfo(Counter, 10) = Format(FreeBytes / TotalBytes, "Percent")
End If
Else ' *** no drive? then set to false
vararyDriveInfo(Counter, 1) = False
End If
Next Counter
End Sub
Sub PrintText(Texty As String)
Dim lPrinter As Long
Dim lRet As Long
Dim lDoc As Long
Dim udtDocInfo As DOCINFO
Dim lWritten As Long
lRet = OpenPrinter(Printer.DeviceName, lPrinter, 0)
If lRet = 0 Then
Exit Sub
End If
udtDocInfo.pDocName = "-"
udtDocInfo.pOutputFile = vbNullString
udtDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lPrinter, 1, udtDocInfo)
Call StartPagePrinter(lPrinter)
lRet = WritePrinter(lPrinter, ByVal Texty, Len(Texty), lWritten)
lRet = EndPagePrinter(lPrinter)
lRet = EndDocPrinter(lPrinter)
lRet = ClosePrinter(lPrinter)
End Sub
Sub SetCursorP(x, Y)
SetCursorPos x, Y
End Sub
Function GetCursorX()
Dim dl&
dl& = GetCursorPos(pt)
GetCursorX = pt.x
End Function
Function GetCursorY()
Dim dl&
dl& = GetCursorPos(pt)
GetCursorY = pt.Y
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -