Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

access the parallel port.

Posted on 1998-06-19
7
Medium Priority
?
408 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
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
Industry Leaders: 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!

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

876 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