| 1 |
Attribute VB_Name = "ModuleUtils" |
Attribute VB_Name = "ModuleUtils" |
| 2 |
|
' (c) Andreas Motl <andreas.motl@ilo.de>, 2007-09-01 |
| 3 |
|
|
| 4 |
Option Explicit |
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) |
Public Sub slog(logString As String) |
| 10 |
'Text1.Text = Text1.Text & logString & vbCrLf |
'Text1.Text = Text1.Text & logString & vbCrLf |
| 11 |
DoEvents |
DoEvents |
| 22 |
args = Split(Command$, " ") |
args = Split(Command$, " ") |
| 23 |
|
|
| 24 |
Dim i As Integer |
Dim i As Integer |
| 25 |
|
'MsgBox UBound(args) |
| 26 |
For i = 0 To UBound(args) |
For i = 0 To UBound(args) |
| 27 |
MsgBox args(i) |
'MsgBox i & ": " & args(i) |
| 28 |
i = i + 1 |
If args(i) = name Then |
| 29 |
|
getCmdArg = args(i + 1) |
| 30 |
|
'i = i + 1 |
| 31 |
|
Exit Function |
| 32 |
|
End If |
| 33 |
Next |
Next |
| 34 |
|
|
| 35 |
End Function |
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 |
|
|