Make your own free website on

Get Windows System Directory

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert this code to the module :

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

'Insert this code to your form:

Private Sub Form_Load()
Dim S As String
S = String(80, 0)
Call GetSystemDirectory(S, 80)
UserName = Left(S, InStr(S, Chr(0)) - 1)
MsgBox (S)
End Sub

Go Back