I’m doing an application that allowed the users to make a reservation for a specific computer, but also I want to do a windows service (installed in every computer), that everytime a user is trying to login into windows, I can validate if that user have a reservation and can use that computer.
Can anyone help me about how to begin with this issue. I did a service and put in some part of the code:
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int operationFlag, int operationReason);
ExitWindowsEx(0, 0);
With ExitWindowsEx (0,0) I can logoff the user if I run the service in Visual Studio, but when I Installed the service that instruction is not working. Any suggestions?
Thank you very much.
I would guess that when you install the service you are running it with the SYSTEM user account, a different user account as when you’re running it from VS. Can you check on services.msc if your service is configured to run with the local system account? If yes, and if you change it to run with your regular user account, and if with that change your code works, then there you have the answer 🙂