Any ideas why DeviceIoControl() would be failing and GetLastError() returning 0x06 = Invalid Handel?
I was writing to the Serial (COMx:) Port fine just before the DeviceIoControl() call.
....
#include <windows.h>
#include <winioctl.h>
.....
#define IOCTL_SERIAL_PURGE CTL_CODE(FILE_DEVICE_SERIAL_PORT,19,METHOD_BUFFERED,FILE_ANY_ACCESS)
...
FILE *pFile;
DWORD flag1=PURGE_TXCLEAR;
DWORD nOutBufferSize=256;
DWORD BytesReturned=0;
struct _OVERLAPPED O1;
char OutBuffer[256]="";
....
pFile = CreateFile("COM4:",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
....
flag1=PURGE_TXCLEAR;
dwError=DeviceIoControl(pFile, IOCTL_SERIAL_PURGE, &flag1, sizeof(flag1), &OutBuffer, nOutBufferSize, &BytesReturned, &O1);
Thanks!
-----------