Solved

Parallel Port Address

Posted on 1997-01-18
1
861 Views
Last Modified: 2013-11-20
From a Win32 app, how can I find the parallel port addresses? (ie, LPT1 is at 0x378, LPT2 is at 0x278, etc).
 
This information is in the BIOS data area at address 04:08, but I don't know how to access that from a 32 bit MFC app.

0
Comment
Question by:ivanm
1 Comment
 
LVL 1

Accepted Solution

by:
glittle earned 200 total points
ID: 1300102
Are you running under Win 3.1, 95, or NT?  

If your using NT, then the best solution is to query the services registery for the parallel port information.  Of course, to use it you will have to be in kernel mode, which means your writing your own device driver.

Outside of NT, the big question here is protected mode and if your application has access to that area of memory that contains your LPT1 and 2 address.  If your app does not have access to that memory in protected mode, you will cause a Trap 13, or GPF.  If you are in Real mode, then you have access to that page, or at least a copy of that page if you are virtual 86 in a Protected mode OS.

The first thing I would try is to build a 32 bit pointer using segment 0 with offset 408 (0000:0408).

typedef struct {
  union {
    int      offset;
    int segment;
    char *pointer;
  }
}POINTER;    

POINTER      aPointer;
int      port;

aPointer.offset = 408;
aPointer.segment = 0;
port = *aPointer.pointer;

You C compiler should have macros that deal with this.  Check for SEGMENT, OFFSET, MAKEP, MAKEPOINTER, MAKEFAR, MAKENEAR, etc.

OR -- you could force assembly and do:
      int      port;

      _asm {
            push es
            push ax
            push dx
            push 0
            pop  ds
            mov  si, 0x0408
            mov  dx, es:[si]
            mov  port, dx
            pop  dx
              pop  ax
                pop  es
      }

If protected mode is a problem, then spawn a real mode program that accesses the memory, writes a file, and terminates.  Your Win32 app then reads the file and gets the LPT1 address from the disk.
Dirty, but workable.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
twoTwo  challenge 35 103
Fibonacci challenge 11 123
Excel file not created as expected 7 72
"Black Box" Testing of Control System Software 2 51
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question