|
-
March 7th, 2002, 01:30 AM
#1
How to get system login time using VB
i want to create a VB application that will record the system time each time a new user logins to the system.
-
March 7th, 2002, 02:59 AM
#2
Re: How to get system login time using VB
This is a starting point:
add a bas module in a project, and remove any form
make the startup object the "Sub Main"
Compile it, and put a shortcut in Startup menu of "all user"
(you may write path and name of shortcut in registry instead, if you know where
to find the "Run" key for all users)
This will write in a file (="c:\temp\LoginTime.txt" username and time of login
each time someone re-login.
This runs on "client side" (ie: if you have 10 pc, you will have to put this
program in all of them, and you will get 10 files, one for each pc)
option Explicit
private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (byval lpBuffer as string, nSize as Long) as Long
Sub Main()
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)
Open "c:\temp\LoginTime.txt" for Append as #1
print #1,
print #1, "---"
print #1, strUserName
print #1, "time loggedIn: " & Now
print #1, "---"
Close 1#
'we have no form
'completed sub main program should stop
'let us make it abruptly
End
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
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
|