473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Windows service not able to capture Login/Lock/Unlock in win7

Windows service not able to capture Login/Lock/Unlock in Win7.
if any one knows the solution or any idea or approach, please help me out.
waiting for all of your positive response.

Thanks in Advance..
Jun 13 '11 #1
6 8707
Joseph Martell
198 Expert 128KB
Any more information? What have you tried so far? Your question makes it sound like you have tried one method and have received unsuccessful results. Is this the case or are you looking for a place to start?

If you are looking for a standard solution, you should investigate the Microsoft.Win32.SystemEvents class.

If you are looking for help with a non-functioning solution, we need more information from you about the solution that you have already tried. Post what you have done and in what way it is specifically failing. Exceptions are a great place to start.
Jun 14 '11 #2
Thanks for time contribution.
I have tried following code:
Expand|Select|Wrap|Line Numbers
  1. SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);System.Events
  2.  
  3. void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
  4. {
  5.     //Console.WriteLine("lock");
  6.     logee.WriteEntry("Inside SystemEvents_SessionSwitch ");
  7.     if (e.Reason == SessionSwitchReason.SessionLock)
  8.     {
  9.         isLockedTmp = true;
  10.     }
  11.     else if (e.Reason == SessionSwitchReason.SessionUnlock)
  12.     {
  13.         isLockedTmp = false;
  14.     }
  15. }
  16.  


the following code is worked finely in winxp but not worked in WS on win7
Jun 14 '11 #3
Joseph Martell
198 Expert 128KB
Interesting. The MSDN documentation says that that same method should work with Windows 7. Unfortunately, I do not have a Windows 7 machine so my testing ability is kind of stunted.

Have you checked the error log to see if there are any entries there? Are you getting any exceptions or anything?
Jun 15 '11 #4
Thanks Joseph for your involvement, actually there is no exception rather then its not reaching the SessionSwitch event. even i have made my machine lock\unlock manually or lock programmatically too.
Jun 15 '11 #5
Joseph Martell
198 Expert 128KB
I had a similar problem with a windows service. It worked on every Windows XP Pro SP3 machine that I could find, but it would not work on Windows XP embedded. My theory was that I needed to add a dependency that I didn't know about.

I would suggest checking your dependencies. In windows xp you have to make sure your service starts after "System Event Notification" (SENS) and "Event Log" (Eventlog), I believe. I assume there are complimentary services in Windows 7 that must be listed as dependencies.

Also, have you tried stopping and restarting your service on the Windows 7 machine? Even though my service would not detect log on/ log off events on the Windows Embedded machine, it would detect the events if I stopped and restarted the service. I couldn't figure out why, but it could at least tell you if it is your code or the way that Windows 7 is handling your service that is the problem.
Jun 17 '11 #6
Plater
7,872 Expert 4TB
Do you need to be run with access to the user's desktop (interactive) in order to catch those events from a service?
Jun 22 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
6
by: Bijesh | last post by:
Hi All, I've developed a Windows Service that acts as a remoting server (.NET Remoting). The client(user) is able to connect to the server and start a program by giving the executable path of...
2
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property...
4
by: gwhite1 | last post by:
I use this code to capture a screen in a regular VB 2005 windows app. It works great! I found the code in google. But when I create a windows service it does not capture the screen. It only...
1
by: hanson | last post by:
How can i create the function of ScreenCapture in the windows service?????
4
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
I know how to capture a keypress for a windows application, but how would I go about doing it for a windows service? Rather than having a form in focus all the time, I would prefer to have...
0
by: =?Utf-8?B?c3VqaXRo?= | last post by:
i have a setup project setup1 which deploys two windows services windows service1,windows service2.i also added some custom installation actions into it using projectinstaller.cs.In windowsservice1...
4
by: =?Utf-8?B?Um9iZXJ0?= | last post by:
I will try to explain the problem. I'm doing an asynchronous copy file from local station to my FTP according to the MSDN example:...
4
by: pbd22 | last post by:
Hi I am making my way through a windows service that accepts custom telnet commands as strings and then parses the string and redirects it. This would be a custom string sent via telnet. ...
6
by: chrisli | last post by:
Hi everyone, i'm trying to Handle the Micosoft.Win32.SessionSwitch Event, so when Windows is going to be locked by the user, i will simply write a line to the console.When it's going to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.