Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;

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

share|improve this question

DWORD = Integer (32-bit signed) WORD = SmallInt (16-bit signed) BYTE do not exist in mapbasic. CHAR may be done as string*1

You have to create another DLL, that sits between mapbasic and your DLL. This DLL should translate to a record format, where Mapbasic understands all the fields.

share|improve this answer
thanks for your response, can you explain further about these DLL's and how this might work, thanks – P Thomas Nov 15 '11 at 21:13
I have assumed this _DCB structure is part of DLL function calls? Since it uses types that mapbasic do not support, you need to write a DLL, that sits as a proxy between the DLL and mapbasic. This should remap the data structure into one that mapbasic understands. That is changing BYTES to WORDS etc. – Uffe Kousgaard Nov 16 '11 at 10:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.