I hide a application like this:
class Program {
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static int SW_SHOW = 5;
static int SW_HIDE = 0;
public static void Main(string[] args)
{
var handle = GetConsoleWindow();
//Hide
ShowWindow(handle, SW_HIDE);
//And more...
}
}
My CurrentDomain_ProcessExit and ConsoleEventCallback events are not working when I hide the program.
I want to run some codes when Windows is shutting down.
Which way do I have to go?(This application is Console Application)