I want to know how come my application get notified for shutdown/log-off event but it does not have UI, so I think WM_ENDSESSION may not work please confirm.
I have also tried SetConsoleCtrlHandler but as I said I do not want any UI (actually I do not want a listing in application tab of task manager) so I gave up this idea too. I do not want to write service either. If there is any method to achieve this. One more thing I do not want to write a driver for this.