Как узнать, в какой каталог была
проинсталлирована Windows?
Declare Function GetTempPath Lib "kernel32"
Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As
Long
Declare Function GetSystemDirectory Lib "kernel32" Alias
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Использование:
Dim sDir As String, sTemp As String * 256
nSize = GetWindowsDirectory(sTemp, 255): sDir = Left(sTemp, nSize)
' sDir = "C:\WINDOWS"
nSize = GetSystemDirectory(sTemp, 255): sDir = Left(sTemp, nSize)
' sDir = "C:\WINDOWS\SYSTEM"
nSize = GetTempPath(255, sTemp): sDir = Left(sTemp, nSize)
' sDir = "C:\WINDOWS\TEMP\"
Примечание: Последняя функция, в
отличие от первых двух, возвращает путь с
завершающим слэшем на конце.
|