| 1 |
Attribute VB_Name = "ModuleUtils" |
| 2 |
' (c) Andreas Motl <andreas.motl@ilo.de>, 2007-09-01 |
| 3 |
|
| 4 |
Option Explicit |
| 5 |
|
| 6 |
' Access the GetUserNameA function in advapi32.dll and call the function GetUserName. |
| 7 |
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long |
| 8 |
|
| 9 |
Public Sub slog(logString As String) |
| 10 |
'Text1.Text = Text1.Text & logString & vbCrLf |
| 11 |
DoEvents |
| 12 |
End Sub |
| 13 |
|
| 14 |
Public Function DirectoryExists(Dir As String) As Boolean |
| 15 |
Dim oDir As New Scripting.FileSystemObject |
| 16 |
DirectoryExists = oDir.FolderExists(Dir) |
| 17 |
End Function |
| 18 |
|
| 19 |
Public Function getCmdArg(name As String) As String |
| 20 |
|
| 21 |
Dim args() As String |
| 22 |
args = Split(Command$, " ") |
| 23 |
|
| 24 |
Dim i As Integer |
| 25 |
'MsgBox UBound(args) |
| 26 |
For i = 0 To UBound(args) |
| 27 |
'MsgBox i & ": " & args(i) |
| 28 |
If args(i) = name Then |
| 29 |
getCmdArg = args(i + 1) |
| 30 |
'i = i + 1 |
| 31 |
Exit Function |
| 32 |
End If |
| 33 |
Next |
| 34 |
|
| 35 |
End Function |
| 36 |
|
| 37 |
' via: http://support.microsoft.com/kb/q152970/ |
| 38 |
Function Get_User_Name() As String |
| 39 |
|
| 40 |
' Dimension variables |
| 41 |
Dim lpBuff As String * 25 |
| 42 |
Dim ret As Long, UserName As String |
| 43 |
|
| 44 |
' Get the user name minus any trailing spaces found in the name. |
| 45 |
ret = GetUserName(lpBuff, 25) |
| 46 |
Get_User_Name = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1) |
| 47 |
|
| 48 |
End Function |
| 49 |
|