Hello everybody.
I would like to make a small program for my university I am in. Just a little bit of history. Very often I see people that have not logged out of their accounts. A bad person can do a lot of damage if you have left your accound logged. What I want to do is to write a program to monitor the user's activity.
Let's say he/she can define a time interval. If there is no activity during this period, the prograt should log off the user automatically.
That's it. So could you guys explain to me the general idea behind this program(programmer's point). How can I monitor the user's activity and stuff like that.
Any help would be greatly appreciated.
With all the respect,
chire

What is the idea behind this program?
DQM
:) (for the last post)
Kiril,
In order to logoff the windows user you can call a Win32 API function
called ExitWindowsEx If you want to call it from within C# code just see
the sample below. The rest of your program will be to keep track of how long
the user has not moved the mouse. After some predefined period elapses
(say 20 mins) you just need to call the ExitWindowsEx function
as I show you below.
Btw
http://www.pinvoke.net/ is a good reference site
showing you how to call a lot of (if not all) Win32 API function from
within managed code. Check also the links provided here:
http://www.pinvoke.net/default.aspx/misc.Suggested%20Reading
using
System;using System.IO;
using
System.Net;using
System.Threading;using
System.Collections;using
System.Configuration;using
System.Diagnostics;using
System.ComponentModel;using
System.Runtime.InteropServices;namespace
WindowsLogoff{
/// <summary> /// ExitWindows. /// </summary>[Flags]
public enum ExitWindows : uint{
// Use ONE of the following five:LogOff = 0x00,
ShutDown = 0x01,
Reboot = 0x02,
PowerOff = 0x08,
RestartApps = 0x40,
// Plus AT MOST ONE of the following two:Force = 0x04,
ForceIfHung = 0x10
}
/// <summary> /// ShutdownReason. /// </summary>[Flags]
public enum ShutdownReason : uint{
MajorApplication = 0x00040000,
MajorHardware = 0x00010000,
MajorLegacyApi = 0x00070000,
MajorOperatingSystem = 0x00020000,
MajorOther = 0x00000000,
MajorPower = 0x00060000,
MajorSoftware = 0x00030000,
MajorSystem = 0x00050000,
MinorBlueScreen = 0x0000000F,
MinorCordUnplugged = 0x0000000b,
MinorDisk = 0x00000007,
MinorEnvironment = 0x0000000c,
MinorHardwareDriver = 0x0000000d,
MinorHotfix = 0x00000011,
MinorHung = 0x00000005,
MinorInstallation = 0x00000002,
MinorMaintenance = 0x00000001,
MinorMMC = 0x00000019,
MinorNetworkConnectivity = 0x00000014,
MinorNetworkCard = 0x00000009,
MinorOther = 0x00000000,
MinorOtherDriver = 0x0000000e,
MinorPowerSupply = 0x0000000a,
MinorProcessor = 0x00000008,
MinorReconfig = 0x00000004,
MinorSecurity = 0x00000013,
MinorSecurityFix = 0x00000012,
MinorSecurityFixUninstall = 0x00000018,
MinorServicePack = 0x00000010,
MinorServicePackUninstall = 0x00000016,
MinorTermSrv = 0x00000020,
MinorUnstable = 0x00000006,
MinorUpgrade = 0x00000003,
MinorWMI = 0x00000015,
FlagUserDefined = 0x40000000,
FlagPlanned = 0x80000000
}
/// <summary> /// MainProgram. /// </summary> class MainProgram{
[DllImport("user32.dll", SetLastError =
true)] static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason); /// <summary> /// The main entry point for the application. /// </summary>[STAThread]
static void Main(string[] args){
ExitWindowsEx(ExitWindows.LogOff, ShutdownReason.MajorSoftware);
}
}
}
Kinlan
Just you needs to do the follwoing
Go to IIS or Web.config file and set the session timeout to specific time (lets say 30min, by default is 20min)
suppose you wants to do some manipulations or some sort of operations during session out, then write a code in session_end method in Global.asax file.
mta37
because as I mentioned in my first post - I am doing this for the university.
As you probably know we have numerous restrictions and one of them is not to use screensaver. :)
Bit Bucket
MMDG
Just you needs to do the follwoing
Go to IIS or Web.config file and set the session timeout to specific time (lets say 30min, by default is 20min)
suppose you wants to do some manipulations or some sort of operations during session out, then write a code in session_end method in Global.asax file.
Shirvo
This wont work if you can't use a screensaver, but it's a nice solution to your problem.
How To Force Users to Quit Programs and Log Off After a Period of Inactivity in Windows XP
Mike36
My, what an environmentally aware university...
Carver42