CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Win32 Programming Help:
How to get the windows user login time


New User

Feb 1, 2010, 4:47 AM

Post #1 of 2 (9461 views)
How to get the windows user login time Can't Post


I want to know how much time the user is logon the system
i done as follows but i didnt get the proper result please help me

my $Server = "";
my $userid = "mahesh";
my $Level = 11;
my %UserInfo = ();
Win32API::Net::UserGetInfo ($Server,$userid,$Level,\%UserInfo);
foreach my $key1 ( keys %UserInfo)
print "Key<$key1>Val<$UserInfo{$key1}>\n";
my @time1 = @{$UserInfo{logonHours}};
print "The Time<@time1>\n";
##O/P is The Time<255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255>

My expected out put is
if a user login at 10.00AM after 30 mins if run this script the o/p should be 00.30
so get this type of out put what the approch i need to be follow please help to me

Thanks & Regards
Mahesh Kumar M


Apr 20, 2010, 10:35 AM

Post #2 of 2 (8522 views)
Re: [mmahesh_mca] How to get the windows user login time [In reply to] Can't Post

You misunderstood the definition of "logonHours". The array which you printed indicates that you have permission to logon at any time. The parameter that you want does not seem to be directly available. It can be computed from by subtracting "lastLogon" from time().

use strict;
use warnings;
use Win32API::Net qw(UserGetInfo);

my $Server = q();
my $Userid = q(mahesh);
my $Level = 2;
my %UserInfo;

UserGetInfo($Server, $Userid, $Level, \%UserInfo);
q(time since login: ),
qq( - $UserInfo{lastLogon} = ),
time() - $UserInfo{lastLogon},
q( seconds),

I have tested this program with ActiveState 5.8.8 and Win32API::New '0.01' under XP HOME

Good Luck
Good Luck,

(This post was edited by BillKSmith on Apr 20, 2010, 11:42 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives