VB-Homepage Tipp 001

Ermitteln des Windows & Windows/Systemverzeichnisses

16Bit
General / Declaration

Declare Function GetWindowsDirectory Lib "Kernel" (ByVal IpBuffer As String, ByVal nSize As Integer) As Integer
Declare Function GetSystemDirectory Lib "Kernel" (ByVal IpBuffer As String, ByVal nSize As Integer) As Integer

32Bit
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

General/WinDir
Function WinDir() As String
Variable1$ = Space$(255)
x% = GetWindowsDirectory(Variable1$, Len(Variable1$))
WinDir = Left$(Variable1$, x%)
End Function

General/SysDir
Function SysDir() As String
Variable2$ = Space$(255)
y% = GetSystemDirectory(Variable2$, Len(Variable2$))
SysDir = Left$(Variable2$, y%)
End Function

Einem Ereignis zuordnen (Beispiel)
Form/Load
Label1.Caption = Trim(WinDir())
Label2.Caption = Trim(SysDir())


Tipp-Download

Quelle :

Zurück zur Übersichtsseite