Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Programmatically Determine if Windows is Shutting Down?

Tags:

c

windows

winapi

I am making an application which runs on our every PC in random times. It works fine, however if the PC is currently shutting down, then I can't read the WMI and i get some errors. So I need to determinate if a PC is shutting down currently, and so i could avoid these errors. Does anyone has an idee?

Thanks!

like image 363
kampi Avatar asked Dec 21 '22 02:12

kampi


1 Answers

Call GetSystemMetrics with index SM_SHUTTINGDOWN (0x2000).

like image 67
Andrew Lambert Avatar answered Jan 29 '23 07:01

Andrew Lambert