ERFORDERLICHE
OBJEKTE
1 Commandbutton (Command1)
FORM-CODE
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Function NetUser()
Dim s As String
Dim cnt As Long
Dim ret As Long
cnt = 199
s = String$(200, 0)
'wenn ret=0 dann niemand angemeldet !
'wenn ret=1 dann jemand angemeldet !
ret = GetUserName(s, cnt)
If ret <> 0 Then
NetUser = Left$(s, cnt)
'Leerzeichen entfernen
pos = InStr(NetUser, Chr$(0))
If pos > 0 Then NetUser = Left$(NetUser, pos - 1)
Else
NetUser = ""
End If
End Function
Private Sub Command1_Click()
MsgBox "Angemeldeter Netzwerkuser: " & NetUser()
End Sub
|