Solved

access the parallel port.

Posted on 1998-06-19
7
399 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now