|
-
Nov 10th, 2000, 07:46 PM
#1
Thread Starter
Member
I know my user name but how read it in source (if you know answer, please write (source) in VB). My OS is Windows 2000.
TNKS!
-
Nov 10th, 2000, 08:08 PM
#2
Fanatic Member
Code:
Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Sub Main()
Dim str_Data As String * 25
Call GetUserName(str_Data, Len(str_Data))
MsgBox Left(str_Data, InStr(str_Data, Chr(0)) - 1)
End Sub
Chemically Formulated As:
Dr. Nitro
-
Nov 10th, 2000, 08:18 PM
#3
Thread Starter
Member
-
Nov 11th, 2000, 01:19 PM
#4
Hyperactive Member
Here's a real simple app I wrote to see who was using my computer at work:
Code:
'Form1 visible property is false
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Private Sub Form_Load()
Dim s As String
Dim cnt As Long
Dim dl As Long
Dim CurUser As String
cnt = 199
s = String$(200, 0)
dl = GetUserName(s, cnt)
If dl <> 0 Then CurUser = Left$(s, cnt) Else CurUser = ""
Open "c:\windows\whoson.log" For Append As #1
Print #1, CStr(Now) & ", User: " & CurUser
Close #1
Unload Form1
Set Form1 = Nothing
End Sub
I put it in the run key in the registry and it runs when you first boot/login. It logs the date
and time and the users login name.
Editting: Forgot the Set statement
[Edited by dsy5 on 11-11-2000 at 01:24 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|