Solved

access the parallel port.

Posted on 1998-06-19
7
405 Views
Last Modified: 2013-11-20
I wish to write data to the parallel port.  How can I do that in MFC?  If possible, can you explain it to me with some example codes?

Thanks in advance.
0
Comment
Question by:rpete
[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
7 Comments
 
LVL 8

Expert Comment

by:trestan
ID: 1318246
0
 

Author Comment

by:rpete
ID: 1318247
trestan,

The source code you have provided is good, but what I am looking for is something in terms of MFC.

Regards,
Peter
0
 

Expert Comment

by:cadothek
ID: 1318248
Did you've ever tried to open "LPT1:" using CFile or derived like a disk file using either Write / Read mode?

0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 7

Expert Comment

by:galkin
ID: 1318249
Port is file in Win32. Use CFile class to open parallel port and then Read/Write functions to Read/Write data to/from the port.
CFile port(_T("LPT1"), CFile::modeReadWrite);
port.Read(...);
port.Write(...);
0
 

Author Comment

by:rpete
ID: 1318250
Hi, I did like you suggested (the listing is listed belong), but when I run the test, it just hung on me.  With the test, I basically, read a file and stream the contents to the LPT port.  BTW, I don't quiet understand the statement:
  CFile port(_T("LPT1"), CFile::modeReadWrite);

the staement '_T("LPT1")' seems to indicate which port I want to address, but what if the port address is not standard or that I want to address LPT2 instead?

Thanks in advance.


CDialog::OnOK();


    CFile cfr, cfw;
    CFile port(_T("LPT1"), CFile::modeReadWrite);

    if(!cfr.Open(strInputPath, CFile::modeRead)){
    AfxMessageBox(_T("Error opening file - read"), MB_OK);
    return;
    }


      cfw.Open(strOutputPath, CFile::modeCreate |    CFile::modeWrite);
    BYTE *buffer = new BYTE[cfr.GetLength()];
      


    UINT bytes = cfr.Read(buffer, cfr.GetLength());
      cfw.Write(buffer, bytes);
      port.Write(buffer,bytes);

    delete [] buffer;
      delete [] workBuffer;
    cfr.Close();
    cfw.Close();
      port.Close();
0
 

Author Comment

by:rpete
ID: 1318251
Adjusted points to 400
0
 
LVL 3

Accepted Solution

by:
shaig earned 400 total points
ID: 1318252
This stuff dosn't work.  When opening the LPT device you are talking with a printer rather then a port.
Sorry, for a Win32 application you will need a Windows 95/NT device driver.
There is documentation in the Windows 95/NT DDK and in various products like WinDK and Vireo.
0

Featured Post

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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