2021年1月19日星期二

C program to determine before an OS state change whether OS is going to Shutdown or Hibernate state to be used in Windows Service

I want to be able to write one value to a file before my computer shuts down and set one more value if computer hibernates. I am looking on how to do this programmatically with C.

I am unable to find a useful C program that demonstrates pre-shutdown event subscription and how to determine whether the action being performed is shutdown or hibernate on Windows OS.

I have seen snippets in C++ and C#; I don't know if they work.

I have the requirement to incorporate this feature in a Windows Service, but that part I will do once I know how to subscribe to Windows power state change events and determine the state being changed to.

https://stackoverflow.com/questions/65802064/c-program-to-determine-before-an-os-state-change-whether-os-is-going-to-shutdown January 20, 2021 at 09:58AM

没有评论:

发表评论