How to access the parallel port


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: How to access the parallel port

  1. #1
    Join Date
    Mar 2006
    Posts
    20

    How to access the parallel port

    Hi Every body
    I'm using MS Studio 2008 On Operating System VISTA Ultimate, i tried to write a program for reading the status of the parallel port and that what i had made
    1-Create a MFC application and called it "ParallelPort"
    2-I added a checkBox and associated it with the bool variable "m_Pin10"
    3-i included the <conio.h> at the begining of ParallelPortDlg.cpp
    4- i created a Fn called void UpdatePins(void) and has the following body
    int reg;
    reg=_inp(0x379);
    if((reg&0x40)==0) m_Pin10=0; else m_Pin10=1;

    5-I created a button to call the Fn UdatePins()

    i compiled the program and after running the application and press the button
    i get an error message(included as attachment)

    is any body know what's wrong with my code,is there other Fn rather than_inp() Fn
    pls advice
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2007
    Posts
    401
    you could try using a hardware access library. eg. WinRing0
    http://openlibsys.org/manual/
    http://sourceforge.net/projects/winring0/

  3. #3
    Join Date
    Nov 2003
    Posts
    4,118
    You can't access the hardware directly in Vista. You need to use a special hardware access library for that purpose, as vijayan said.
    Danny Kalev

  4. #4
    Join Date
    Mar 2006
    Posts
    20
    thanks vijayan & Danny
    i downloaded WinRing0 but didn't know how to use it in my program would you please tell me how to do it

  5. #5
    Join Date
    Dec 2007
    Posts
    401
    1. unpack the zip file.
    2. read the extracted file manual.chm - section "How to Use"
    Code:
    How to Use 
    Common
    Put WinRing0.dll, WinRing0x64.dll, WinRing0.sys, WinRing0x64.sys, and WinRing0.vxd 
    into the directory where your application's executable file resides.
    
    Visual C++ 2005/2008 
    See also sample application. 
    
    Load-Time Dynamic Linking 
    Add WinRing0.lib or WinRing0x64.lib to your project. 
    Add #include "OlsApi.h" statement to your source file. 
    Call InitializeDll(). 
    Call the library's functions. 
    Call DeinitializeDll(). 
    ...
    3. in manual.chm - section "Core API" read about the functions of interest to uou.
    eg. ReadIoPortWord, WriteIoPortWord

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    There are publications for this product on this site.

    http://www.bto.org/software/ipmr/winring.htm
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  7. #7
    Join Date
    Mar 2006
    Posts
    20
    this is my Fn

    void CParallelPortDlg::UpdatePins(void)
    {
    unsigned char reg;
    InitializeDll();
    reg=ReadIoPortByte(0x378);
    if((reg&0x40)==0) m_Pin10=0; else m_Pin10=1;
    DeinitializeDll();
    }
    When i applied the instructions in the manual i got these errors

    ParallelPortDlg.obj : error LNK2019: unresolved external symbol "void __stdcall DeinitializeDll(void)" (?DeinitializeDll@@YGXXZ) referenced in function "public: void __thiscall CParallelPortDlg::UpdatePins(void)" (?UpdatePins@CParallelPortDlg@@QAEXXZ)

    1>ParallelPortDlg.obj : error LNK2019: unresolved external symbol "unsigned char __stdcall ReadIoPortByte(unsigned short)" (?ReadIoPortByte@@YGEG@Z) referenced in function "public: void __thiscall CParallelPortDlg::UpdatePins(void)" (?UpdatePins@CParallelPortDlg@@QAEXXZ)

    1>ParallelPortDlg.obj : error LNK2019: unresolved external symbol "void __stdcall InitializeDll(void)" (?InitializeDll@@YGXXZ) referenced in function "public: void __thiscall CParallelPortDlg::UpdatePins(void)" (?UpdatePins@CParallelPortDlg@@QAEXXZ)

    1>C:\Users\Falcon Eyes\Documents\Visual Studio 2008\Projects\ParallelPort\Debug\ParallelPort.exe : fatal error LNK1120: 3 unresolved externals

  8. #8
    Join Date
    Dec 2007
    Posts
    401
    add the import library WinRing0.lib (or WinRing0x64.lib for 64 bit) to your project.

Similar Threads

  1. parallel port
    By intan411 in forum VB Classic
    Replies: 0
    Last Post: 07-28-2006, 10:18 AM
  2. Replies: 2
    Last Post: 01-16-2006, 03:34 PM
  3. ..or maybe Access will work after all...
    By David Jones in forum Database
    Replies: 5
    Last Post: 09-02-2001, 03:17 AM
  4. Replies: 0
    Last Post: 11-20-2000, 05:37 AM
  5. Read Parallel Port Data
    By Dee in forum VB Classic
    Replies: 0
    Last Post: 05-04-2000, 06:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center