Windows C program performs shutdown action

I am making a program that sends "heartbeats" to the server to track nodes. These are packages with the following payloads:

  • 'start' at startup

  • 'running' every 5 seconds

  • "stop" when turned off

The first two are easy. A thread / loop can set a message for the first and subsequent starts. How to make the loop "catch" shutdown so that it can send the last packet?

I am using the minGW compiler for the C platform in WinXP.

Edit: I added relevant details that I missed (thanks walkTarget and Ferruccio)

  • This is an unfinished application that contains messy things in the implementation :-)
  • It uses libCURL, the HTTP client library to send packets
  • This is a console application that I (much later) intend as a service
  • It should save the file and send the package at shutdown
  • He needs to fix the system shutdown
+3
source share
1 answer

In your WindowProc (), you can check the WM_QueryEndSession message that Windows sends to all open processes before closing. For more information about this post, see the following link, but I understand that this is as trivial as the WM_SIZE check:

http://msdn.microsoft.com/en-us/library/aa376890%28VS.85%29.aspx

+1
source

Source: https://habr.com/ru/post/1795247/


All Articles