Solved

access the parallel port.

Posted on 1998-06-19
7
401 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 84
Best tools for Backup and restore of Wordpress site 6 57
zeroMAx challenge 20 103
how to split multiple lines delimiter : 8 99
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 …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 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