Solved

Parallel Port Address

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

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 84
Define unique primary key 9 95
NotAlone Challenge 20 88
I could not set window to top 4 45
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 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