API- Programmierung
Befehl / Beispiele Beschreibung
GetAsyncKeyState Tastaturüberwachung
Beispiel:
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Sub AbbruchTest()
    Do
      Cells(20, 1) = Cells(20, 1) + 1
    Loop Until GetAsyncKeyState(27) <> 0          ' Schleifenabbruch, wenn Esc-Taste gedrückt.
                                                        ' 27 = Ansi-Code Esc-Taste
    MsgBox "Programmabbruch"                     
End Sub
GetSystemMetrics Bildschirmauflösung ermitteln
Beispiel:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Sub Auflösung_Test()
    Dim X As Long
    Dim Y As L ong

    Auflösung X, Y
    MsgBox "Die Auflösung beträgt " & X & " x " & Y
End Sub

Sub Auflösung(X, Y)
'+--------------------------------------------------------------------+
'|  Bildschirmauflösung ermitteln über die Funktion GetSystemMetrics  |
'+--------------------------------------------------------------------+
    X = GetSystemMetrics(0) ' horizontal
    Y = GetSystemMetrics(1) ' vertikal
End Sub
GetSystemDirectory Sytem32-Verzeichnis ermitteln
Beispiel:
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
       (ByVal lpBuffer As String, _
        ByVal nSize As Long) As Long

Sub TestGetSysDir()
    MsgBox GetSysDir
End Sub

Function GetSysDir() As String
'+------------------------------------------------+
'|  Ermittlung des Systemverzeichnisses System32  |
'+------------------------------------------------+
    Dim AzZeichen As Long
    Dim SystemVerz As String

    SystemVerz = Space(255)
    AzZeichen = GetSystemDirectory(SystemVerz, 255)
    SystemVerz = Left(SystemVerz, AzZeichen)

    GetSysDir = SystemVerz
End Function
GetTickCount Wie lange läuft Windows schon
Beispiel:
Declare Function GetTickCount Lib "kernel32" () As Long

Function WindowsLaufzeit() As Date
    WindowsLaufzeit = GetTickCount() / 24 / 3600 / 1000
End Function

Sub Test_WindowsLaufzeit()
    MsgBox WindowsLaufzeit
End Sub
Verzeichnis wählen