Skip to main content
2 of 2
code formatting, make title clearer, remove unnecessary info at end

Declarations required for Mapbasic api calls

I am trying to read a serial port by using api calls createfile, readfile, getcommstate, setcommstate etc...

this all requires the proper declaration of a structure "dcb"

typedef struct _DCB {
 DWORD DCBlength;
 DWORD BaudRate;
 DWORD fBinary  :1;
 DWORD fParity  :1;
 DWORD fOutxCtsFlow  :1;
 DWORD fOutxDsrFlow  :1;
 DWORD fDtrControl  :2;
 DWORD fDsrSensitivity  :1;
 DWORD fTXContinueOnXoff  :1;
 DWORD fOutX  :1;
 DWORD fInX  :1;
 DWORD fErrorChar  :1;
 DWORD fNull  :1;
 DWORD fRtsControl  :2;
 DWORD fAbortOnError  :1;
 DWORD fDummy2  :17;
 WORD  wReserved;
 WORD  XonLim;
 WORD  XoffLim;
 BYTE  ByteSize;
 BYTE  Parity;
 BYTE  StopBits;
 char  XonChar;
 char  XoffChar;
 char  ErrorChar;
 char  EofChar;
 char  EvtChar;
 WORD  wReserved1;
} DCB, *LPDCB;

My first question is how would you declare this in mapbasic? Then how to determine the structures length?