From: Rick Raisley on
I now realize that it doesn't matter when Windows starts, or when the PC is
turned on. As I'm trying to determine the state of a program run as the
user, what I need to determine is when a user logged into his PC. Then when
my program first runs, it will log its start time, and compare its previous
start time with the time the user last logged in. If the last run time was
before when the user logged in, then it's the first time the program is
being run.

So - does anyone have any ideas on how to determine the DATE & TIME that the
current user Logged In to his PC? A Google hasn't gotten me anything, yet.

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net

"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:%23gbP5gZ7IHA.3696(a)TK2MSFTNGP04.phx.gbl...
> Basically, I want my VB6 app to do something different the first time it
> runs, after the PC is restarted, than any other times. I want it to be
> triggered by my app (not just have an app in the Startup group), so if it
> is never run, it isn't needed. But I want my app to update a data file
> from a remote location the first time it runs. If run again, before the
> computer is restarted, I don't want it to update the data file.
>
> So, how do I determine that it has run once? I can make a log file, of
> course, to determine it has run. But that could be a minute ago or last
> week, before many restarts. I guess I could put a batch file in the
> Startup group that would delete the log file, then create it the first
> time the program runs. That would work, but seems kludgy.
>
> Any better ideas?
>
> --
> Regards,
>
> Rick Raisley
> heavymetal-A-T-bellsouth-D-O-T-net
>
>


From: Steve Easton on
Check the time stamp of %UserProfile%\NTUSER.DAT ?

--

Steve Easton





"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:uJTSU4o7IHA.4040(a)TK2MSFTNGP06.phx.gbl...
>I now realize that it doesn't matter when Windows starts, or when the PC is turned on. As I'm trying to
>determine the state of a program run as the user, what I need to determine is when a user logged into his PC.
>Then when my program first runs, it will log its start time, and compare its previous start time with the
>time the user last logged in. If the last run time was before when the user logged in, then it's the first
>time the program is being run.
>
> So - does anyone have any ideas on how to determine the DATE & TIME that the current user Logged In to his
> PC? A Google hasn't gotten me anything, yet.
>
> --
> Regards,
>
> Rick Raisley
> heavymetal-A-T-bellsouth-D-O-T-net
>
> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
> news:%23gbP5gZ7IHA.3696(a)TK2MSFTNGP04.phx.gbl...
>> Basically, I want my VB6 app to do something different the first time it runs, after the PC is restarted,
>> than any other times. I want it to be triggered by my app (not just have an app in the Startup group), so
>> if it is never run, it isn't needed. But I want my app to update a data file from a remote location the
>> first time it runs. If run again, before the computer is restarted, I don't want it to update the data
>> file.
>>
>> So, how do I determine that it has run once? I can make a log file, of course, to determine it has run. But
>> that could be a minute ago or last week, before many restarts. I guess I could put a batch file in the
>> Startup group that would delete the log file, then create it the first time the program runs. That would
>> work, but seems kludgy.
>>
>> Any better ideas?
>>
>> --
>> Regards,
>>
>> Rick Raisley
>> heavymetal-A-T-bellsouth-D-O-T-net
>>
>>
>
>


From: Steve Easton on
Disregard that. It changes.


"Steve Easton" <admin(a)95isalive.com> wrote in message news:OQPNmDq7IHA.2016(a)TK2MSFTNGP02.phx.gbl...
> Check the time stamp of %UserProfile%\NTUSER.DAT ?
>
> --
>
> Steve Easton
>
>
>
>
>
> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
> news:uJTSU4o7IHA.4040(a)TK2MSFTNGP06.phx.gbl...
>>I now realize that it doesn't matter when Windows starts, or when the PC is turned on. As I'm trying to
>>determine the state of a program run as the user, what I need to determine is when a user logged into his
>>PC. Then when my program first runs, it will log its start time, and compare its previous start time with
>>the time the user last logged in. If the last run time was before when the user logged in, then it's the
>>first time the program is being run.
>>
>> So - does anyone have any ideas on how to determine the DATE & TIME that the current user Logged In to his
>> PC? A Google hasn't gotten me anything, yet.
>>
>> --
>> Regards,
>>
>> Rick Raisley
>> heavymetal-A-T-bellsouth-D-O-T-net
>>
>> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
>> news:%23gbP5gZ7IHA.3696(a)TK2MSFTNGP04.phx.gbl...
>>> Basically, I want my VB6 app to do something different the first time it runs, after the PC is restarted,
>>> than any other times. I want it to be triggered by my app (not just have an app in the Startup group), so
>>> if it is never run, it isn't needed. But I want my app to update a data file from a remote location the
>>> first time it runs. If run again, before the computer is restarted, I don't want it to update the data
>>> file.
>>>
>>> So, how do I determine that it has run once? I can make a log file, of course, to determine it has run.
>>> But that could be a minute ago or last week, before many restarts. I guess I could put a batch file in the
>>> Startup group that would delete the log file, then create it the first time the program runs. That would
>>> work, but seems kludgy.
>>>
>>> Any better ideas?
>>>
>>> --
>>> Regards,
>>>
>>> Rick Raisley
>>> heavymetal-A-T-bellsouth-D-O-T-net
>>>
>>>
>>
>>
>
>


From: Jim Carlock on
"Steve Easton" <admin at 95isalive.com> wrote...
: Check the time stamp of %UserProfile%\NTUSER.DAT ?

"Steve Easton" <admin at 95isalive.com> wrote:
: Disregard that. It changes.

Yep, everytime you change something in the HKEY_CURRENT_USER key
it changes.

My first thoughts were to scan through the System event log, but
that's too intensive. There's probably a key somewhere in the reg
that identifies the logon time. I didn't find it on first looks,
so perhaps someone else knows where to find it. Not sure if that
applies to FAT32 systems though (may require NTFS).

--
JCarlock
Natural Cure For Pink-Eye (Conjunctivitis)
http://www.associatedcontent.com/article/381336/saliva_a_natural_cure_for_conjunctivitis.html


From: expvb on
See NetUserGetInfo() and usri2_last_logon member in USER_INFO_2 structure.
You will have to use several API calls before using it, such as
GetUserName/GetComputerName/Ex.

Another way is putting your application in HKLM\...\Run at install time with
a command line, like the following:

<AppPath>\MyApp.exe /startup

The Command() function returns the command line options. You can use that to
save the date and time and exit.

The Run entries in HKLM are executed for every user that logs in, including
terminal services and fast user switching.