When installing Windows some people do not install it on the default "C" directory. Therefore when writing a application you should never assume that the Windows and System directory is located on the "C" drive. This tip shows how to find the Windows and System directories no matter where they are located.

==============================================================
'Declare the following in a Bas file

Private Declare Function GetWindowsDirectory _
Lib "kernel32" Alias "GetWindowsDirectoryA" ( _
ByVal lpBuffer As String, _
ByVal nSize As Long) _
As Long

Private Declare Function GetSystemDirectory _
Lib "kernel32" Alias "GetSystemDirectoryA" ( _
ByVal lpBuffer As String, _
ByVal nSize As Long) _
As Long


Public Function GetSysDir() As String
Dim Temp As String * 256
Dim x As Integer
x = GetSystemDirectory(Temp, Len(Temp))
GetSysDir = Left$(Temp, x)
End Function

Public Function GetWinDir() As String
Dim Temp As String * 256
Dim x As Integer
x = GetWindowsDirectory(Temp, Len(Temp))
GetWinDir = Left$(Temp, x)
End Function

*****************************************************

Private Sub Form_Click()
MsgBox "Windows Dir:" & vbTab & GetWinDir() & _
vbCrLf & "System Dir:" & vbTab & GetSysDir()
End Sub