![]() |
|
Tipp 0132
|
Windows-Verzeichnis ermitteln
|
 |
|
Autor/Einsender: Datum: |
|
Daniel Fiedler 26.09.2001 |
|
| Entwicklungsumgebung: |
|
VB 5 |
|
|
|
Mithilfe der API-Funktion GetWindowsDirectory ist es möglich, recht einfach
und mit wenigen Handgriffen das Verzeichnis des Betriebssystems herauszufinden.
|
|
| |
Option Explicit
Private Declare Function GetWindowsDirectory Lib "kernel32" _
Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Function GetWinDir() As String
Dim strDir As String
Dim nLen As Long
strDir = Space(255)
nLen = GetWindowsDirectory(strDir, 255)
strDir = Left(strDir, nLen)
If Right$(strDir, 1) <> "\" Then strDir = strDir & "\"
GetWinDir = strDir
End Function
|
|
|
|
|
| |
MsgBox "Windows-Verzeichnis: " & GetWinDir
|
|
|
|
|
|
|
|
|
|
Der hier abgebildete Code funktioniert auch in einem VBA-Projekt, dieser muss dazu
lediglich in den VB-Editor der entsprechenden Anwendung kopiert werden. Ein Import
der im Download enthaltenen *.frm-Datei ist nicht möglich.
|
|
| Windows-Version |
| 95 |
 |
|
| 98/SE |
 |
|
| ME |
 |
|
| NT |
 |
|
| 2000 |
 |
|
| XP |
 |
|
| Vista |
 |
|
| Win
7 |
 |
|
|
| VB-Version |
| VBA 5 |
 |
|
| VBA 6 |
 |
|
| VB 4/16 |
 |
|
| VB 4/32 |
 |
|
| VB 5 |
 |
|
| VB 6 |
 |
|
|
|
Download (2 kB)
|
Downloads bisher: [ 1429 ]
|
|
|