// Detecting available LPT ports on an IBM PC
// Borland C++ for DOS
// Stephen Russell Warren <srw1@doc.ic.ac.uk>
#include <stdio.h>
#include <dos.h>
#define MAXLPT 3
void main(void) {
int lptno;
unsigned lptaddr[MAXLPT];
for (lptno=0; lptno<MAXLPT; lptno++) {
lptaddr[lptno]=*(unsigned far *)(MK_FP(0x40, 0x008+(lptno*2)));
if (lptaddr[lptno]) {
printf("LPT%d found at 0x%04x\n", lptno+1, lptaddr[lptno]);
} else {
printf("LPT%d not found\n", lptno+1);
}
}
}
What's all this 0x40, 0x008 stuff ? - see
A note on 8086/88 Memory Segmentation
last updated: 12-Mar-97 Ian Harries <ih@doc.ic.ac.uk>