' Расположение папки Windows
' Добавить в форму TextBox
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
"GetWindowsDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Public Function WindowsDirectory() As String
On Error GoTo Err_
Dim WinPath As String
Dim Rtn As Integer
Const MAXWINPATH = 200
WinPath = Space$(MAXWINPATH)
Rtn = GetWindowsDirectory(WinPath, MAXWINPATH)
WindowsDirectory = StrZ(WinPath)
Ex_:
Exit Function
Err_:
Resume Ex_
End Function
Private Function StrZ(par As String) As String
Dim nSize As Long, i As Long, Rez As String
nSize = Len(par)
i = InStr(1, par, Chr(0)) - 1
If i > nSize Then i = nSize
If i < 0 Then i = nSize
StrZ = Mid(par, 1, i)
End Function
Private Sub Form_Load()
' Windows дириктория
Dim WinDir As String
WinDir = WindowsDirectory
Text1.Text = WinDir
End Sub
Системная информация (2 797 байт)