Solved

Parallel Port Address

Posted on 1997-01-18
1
849 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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 …
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now