
Untitled
By: a guest on
May 25th, 2012 | syntax:
None | size: 0.66 KB | hits: 10 | expires: Never
C WIN32: Running a program without a command prompt window
#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;
}
#define _WIN32_WINNT 0x0500
#define _WIN32_WINNT 0x0500