I have written a program which triggers a relay switch on a serial port. The relay is closed for 10ms, after which the program closes. However, the program insists on running in a small command prompt window. I would like the program to run without stealing focus; either by running in the background or, even better, without opening a window at all.
Here is the complete program:
#include <windows.h>
//Initialise Windows module
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, int nFunsterStil)
{
//Define the serial port precedure
HANDLE hSerial;
//Open the port
hSerial = CreateFile("COM1",GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
//Switch on relay
EscapeCommFunction(hSerial, SETDTR);
//Wait 10ms
Sleep(10);
//Switch off relay
EscapeCommFunction(hSerial, CLRDTR);
//Close the port
CloseHandle(hSerial);
//End with error code 0
return 0;
}
What must I change in order to prevent it running in a window?
yourapp.exe /NOCONSOLEparameter?