Monday, January 31, 2011

VB Get Windir & Sys32dir

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

Public Function WINdir() As String
Dim str As String
str = String(20, Chr$(0))
GetWinDir str, 20
WINdir = ClrNol(str)
End Function

Public Function S32dir() As String
Dim str As String
str = String(20, Chr$(0))
GetWinDir str, 20
S32dir = ClrNol(str) & "\system32"
End Function

Public Function ClrNol(Ctx As String) As String
ClrNol = Left(Ctx, Len(Ctx) - InStr(Ctx, Chr$(0)) + 1)
End Function

No comments:

Post a Comment