Solved

Parallel Port Address

Posted on 1997-01-18
1
874 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
In this post we will learn different types of Android Layout and some basics of an Android App.
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

724 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