--- Letakkan di module
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
'--- Akhir Letakkan di module
Public Function GetSysDir() As String
Dim boolRetVal As Boolean, lpBuffer As String, nSize As Long
lpBuffer = Space(255): nSize = 254
boolRetVal = GetSystemDirectory(lpBuffer, nSize)
GetSysDir = StripNullTerminator(lpBuffer)
End Function
Function StripNullTerminator(lpBuffer As String) As String
Dim I As Integer
For I = 1 To 255
If Asc(Mid(lpBuffer, I, 1)) = 0 Then
lpBuffer = Left(lpBuffer, I - 1)
Exit For
End If
Next I
StripNullTerminator = lpBuffer
End Function
Private Sub Form_Load()
MsgBox GetSysDir
End Sub