Link to home
Start Free TrialLog in
Avatar of Akhterrehan
Akhterrehan

asked on

How to get notification of User LogIn from a Console Service

I have a console service developed in MFC using VS2005.

My service should know when a User Logs in to the system so that it can take some user specific actions.

Is there a way by which my console service can know when a user logs in ?
Avatar of jkr
jkr
Flag of Germany image

Use a Winlogon Notification Package for that purpose: http://msdn2.microsoft.com/en-us/library/aa380545.aspx ("Winlogon Notification Packages")

The scoop is to export a set of functions that Winlogon calls for each logon/logoff event

// Here is the event handler for the Winlogon Logon event.
extern "C" VOID APIENTRY WLEventLogon (PWLX_NOTIFICATION_INFO pInfo)
{

    // Print the name of the handler to debug output.
    // You can replace this with more useful functionality.
    OutputDebugString (TEXT("NOTIFY:  Entering WLEventLogon.\r\n"));
}

// Here is the event handler for the Winlogon Logoff event.
extern "C" VOID APIENTRY WLEventLogoff (PWLX_NOTIFICATION_INFO pInfo)
{

    // Print the name of the handler to debug output.
    // You can replace this with more useful functionality.
    OutputDebugString (TEXT("NOTIFY:  Entering WLEventLogff.\r\n"));
}

(http://msdn2.microsoft.com/en-us/library/aa375405.aspx - "Event Handler Function Prototype")

and register them accordingly as described in http://msdn2.microsoft.com/en-us/library/aa379402.aspx ("Registry Entries")

See also http://msdn2.microsoft.com/en-us/library/aa374783.aspx ("Creating a Winlogon Notification Package") and http://msdn2.microsoft.com/en-us/library/aa379380.aspx ("Registering a Winlogon Notification Package")
Avatar of Akhterrehan
Akhterrehan

ASKER


Tried using it. Through it i have managed to start my application in either SYSTEM or LoggedOn user rights.

1. When running my application as a SYSTEM application, i am unable to display any GUI on the desktop.

2. When running my application as a LOGED in User application, my application gets very little priveleges.

Is there any way by which an application running in SYSTEM can display GUI in the desktop of the LoggedIN User.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin