Get windows system directory

How can I retrieve the Windows root directory or the system32 directory?
I've been looking for an API GetSystemRoot or GetWindowsRoot or something like that with no result...
LVL 3
boemanAsked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
Or

Option Explicit
Private Declare Function GetSystemDirectory Lib "KERNEL32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub Command1_Click()
    Dim strBuf As String

    strBuf = Space$(255)
    GetSystemDirectory strBuf, 255
    strBuf = Left$(strBuf, InStr(strBuf, Chr$(0)) - 1)
    Debug.Print strBuf
End Sub
0
 
DhaestCommented:
Try:
environ("windir")
0
 
boemanAuthor Commented:
muchos gracias
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.