Hej,Sv: Windows login
Använd API funktionen "GetUserName". Ett litet exempel:
<code>
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
Dim strUserName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get the username
GetUserName strUserName, 100
'strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
'Show the username
MsgBox "Hello " & strUserName
End Sub
</code>
Obs, det är ett snabbt ihopslängt exempel, så det är inget mönster exempel, utan mest för att visa hur man gör.
// Johan