Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

access the parallel port.

Posted on 1998-06-19
7
Medium Priority
?
407 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
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 800 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

Technology Partners: 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: 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 …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

719 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