1

I have an application in .NET now i am recoding it using Python and PyQt. In my application i need to know system events (Lock,Logoff,Restart and Shutdown). I could able to manage it from .NET Frame work 3.5 using below snippit

AddHandler SystemEvents.SessionEnding, AddressOf ClosingApplication
AddHandler SystemEvents.SessionSwitch, AddressOf SessionSwitchEvent

Depending on the system i need to do some stuff to update my Database.

Can any one help me plz...

Rao
  • 2,902
  • 14
  • 52
  • 70

1 Answers1

1

You are going to need to use the pywin32 library. It is a wrapper class for the win32api. You can then use the SetConsoleCtrlHandler to catch the signal.

To cleanly capture the signal you are going to need to spawn a console window. To make your application run cleanly, you can run the console window in a hidden state. For more information about how to spawn the console window see: Python - Windows Shutdown Events

Community
  • 1
  • 1
BigHandsome
  • 4,843
  • 5
  • 23
  • 30