ZjiÜt∞nφ zßkladnφch adresß°∙ Windows

Postup:
V modulu deklarujte:
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nSize As Long, ByVal lpBuffer As String) As Long
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

*Ka₧dß deklarace musφ b²t celß na samostatnΘ °ßdce

Private Function GetWinDir() As String

    Dim r As Long
    Dim nSize As Long
    Dim tmp As String
   tmp = Space$(256)
   nSize = Len(tmp)
    r = GetWindowsDirectory(tmp, nSize)

    GetWinDir = TrimNull(tmp)

End Function

Public Function GetTempDir() As String

    Dim r As Long
    Dim nSize As Long
    Dim tmp As String
    tmp = Space$(256)
    nSize = Len(tmp)
    r = GetTempPath(nSize, tmp)
    GetTempDir = TrimNull(tmp)

End Function

Private Function GetSystemDir() As String

    Dim r As Long
    Dim nSize As Long
    Dim tmp As String
    tmp = Space$(256)
    nSize = Len(tmp)
    r = GetSystemDirectory(tmp, nSize)
    GetSystemDir = TrimNull(tmp)

End Function

Private Function TrimNull(item As String)

    Dim pos As Integer
    pos = InStr(item, Chr$(0))
    If pos Then
        TrimNull = Left$(item, pos - 1)
    Else
        TrimNull = item
    End If

End Function

Ve formulß°i, na udßlost Click tlaΦφtka:
Private Sub Command1_Click()

    Label1 = GetWinDir()
    Label2 = GetTempDir()
    Label3 = GetSystemDir()

End Sub

Spus¥te projekt. Po kliknutφ na tlaΦφtko se do jednotliv²ch jmenovek vyplnφ p°φsluÜnΘ ·daje.

Zp∞t

Autor: The Bozena