flat assembler
Message board for the users of flat assembler.

Index > Windows > Monitor user login/logoff

Author
Thread Post new topic Reply to topic
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36 28 Mar 2006, 11:10
Hello! I want to relearn ASM-programming... i loved it back in the OS/290 days! Today i'm using a WinXP(32)-Machine and want to code the following:

Every time a user logs in or off, some infos about this get written to the database|logfile.

I tried to find some infos on how to do this and first thought about a Windows-Hook, but this seems to be not an efficient way, since i don't want to intercept with other programs etc. My next thought was to create an autostart-entry, and every time the user logs in, a tiny program gets started.

But how can i monitor if a user logs off? I found the ExitWindows API-Call, but have no clue how to make sort of a "watchdog"-program, waiting for this call. Is there a way in windows to autostart programs when the user logs off?

Thanks for the help in advance!
Post 28 Mar 2006, 11:10
View user's profile Send private message Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin 28 Mar 2006, 12:35
if you leave the program running when the user logs in, you can process
the WM_QUERYENDSESSION and WM_ENDSESSION messages.

they inform you when a logoff/restart etc is about to take place.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shutdown/base/wm_endsession.asp
Post 28 Mar 2006, 12:35
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 28 Mar 2006, 12:38
why not the hook?
Post 28 Mar 2006, 12:38
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36 28 Mar 2006, 12:40
Ahh. Great, thank you wisepenguin!

About the hook: i read in Icezelion's Win32 Hook tutorial about the several types of hooks and understood it so, that hooks only make sense when you want to trap events in other applications. Now, after reading the tut a second time, i think i was wrong, hehe... So you would suggest a hook? I think for my purpose this maybe would not make much sense, since at logon i autostart a program which, at logoff, receives the WM_QUERYENDSESSION call to shutdown... There are no other events i need...?

After reading the help about WM_QUERYENDSESSION, i think it works this way (please correct me): Windows sends WM_QUERYENDSESSION to all programs. If mine and all others return 0, then Windows checks the results and returns WM_ENDSESSION to all programs to let them know if Windows is shutting down?
Post 28 Mar 2006, 12:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.