The only way to get messages is by a message loop and a window procedure.
If your program does not have a visible gui, you have to create a message-only window for that purpose, and your main
must have the code to create it and to listen windows messages (note: "windows" here, refers to the system, not the gui).