Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C   WIN32: Running a program without a command prompt window
  2. #include <windows.h>
  3.  
  4. //Initialise Windows module
  5. int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
  6. LPSTR lpszArgument, int nFunsterStil)
  7. {
  8.  //Define the serial port precedure
  9.  HANDLE hSerial;
  10.  
  11.  //Open the port
  12.  hSerial = CreateFile("COM1",GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  13.  
  14.  //Switch on relay
  15.  EscapeCommFunction(hSerial, SETDTR);
  16.  
  17.  //Wait 10ms
  18.  Sleep(10);
  19.  
  20.  //Switch off relay
  21.  EscapeCommFunction(hSerial, CLRDTR);
  22.  
  23.  //Close the port
  24.  CloseHandle(hSerial);
  25.  
  26.  //End with error code 0
  27.  return 0;
  28. }
  29.        
  30. #define _WIN32_WINNT 0x0500
  31.        
  32. #define _WIN32_WINNT 0x0500