ReadFile()/WriteFile() for LPTX isn't working RRS feed

  • Discussion générale

  • Hello.

    I open parallel port LPT1 with the win32 api function CreateFile() successfully but when i try to read or write data, it doesn't work..

    After ReadFile(), GetLastError() returns 1 and no Byte have been read (nb == 0)

    And WriteFile() freeze...

    m_hLPT = CreateFile( _T("LPT1:"), GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, NULL ); BOOL write, read; usigned char data = 'a'; DWORD nb; BYTE buff[3] = {0}; if ( m_hLPT != INVALID_HANDLE_VALUE){ // WRITE write = WriteFile( m_hLPT, &data, sizeof(usigned char), &nb, NULL ); // ... // READ read = ReadFile( m_hLPT, buff, sizeof(buff), &nb, NULL ); // ... }

    Any ideas why it isn't working ?

    Thank you for your help.

    jeudi 24 mai 2012 13:22

Toutes les réponses

  • 。。。。。。。。。。

    open parallel port LPT1 with OpenFile.


    Please mark this reply as answer if it helps you! Thanks for your cooperation! Good Luck to you.

    vendredi 25 mai 2012 07:30
  • From Windows 2000 onwards support for writing and reading to the lpts ports no longer exists.

    There is a third party dll that you can use for this purpose. "inpout32.dll"

    I think also there is a 64bit version around.

    Google it and you will find a lot of info and examples for it.



    vendredi 25 mai 2012 07:34