Click here to Skip to main content
Click here to Skip to main content

Kport Direct Access I/O Ports Under Win NT/2000/XP

By , 6 Apr 2005
 

Sample Image - kport.jpg

Introduction

I wrote this DLL for implementing direct access I/O ports in Windows NT/2K/XP.

Background

For compiling the project, you need VC7.1-2003. For compiling kioport.sys, you need to install the DDK. Kioport is based on PortTalk.sys from the article: "Beyond Logic Port Talk I/O Port Driver", http://www.beyondlogic.org/, and "A DDK's project wizard for VC2003", http://www.codeproject.com/KB/macros/ddkwizard.aspx.

Using the code

  1. Copy kioport.sys to \windows\system32\drivers.
  2. Add kioport.reg to register windows.
  3. Reboot windows for activate service in the register of windows.
  4. Add kport.h in your project and kport.lib.
  5. Put Kport.dll in the same directory as the application.

Using the Kport DLL is so easy. Here is the function definition, and the explanation follows:

// Returns a value from specific ports.
BYTE Inportb(WORD PortNum);
            
// Write a value to specific ports.
void Outportb(WORD PortNum, BYTE byte);
  • PortNum: is the port number; for example: 0x378 (LPT1).
  • BYTE: data to send for a specific PortNum in Ouportb, and data received in Inportb.

How to use the sample dialog

  • Write a number bellow the text 'Write Value( )', and click in the Write button.
  • Click on the Read button.

History

  • First version: April 3, 2005.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Guerino Palacios
Web Developer
Argentina Argentina
Member
I'm Javier Güerino Palacios.
I know MFC, PHP, C, C++, C#, Java, ASM-8086.
I study Ing. Electronics and Ing. Information systems.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalerror after include video.hmemberjavad_20057 Aug '07 - 6:21 
Hello
I need to use a ddk and used aall wizard of ddk
i just could include ntddk.h but
when include other file like video.h it give me
many error.
thanks
QuestionProblem during read operation...memberdarxoul16 Nov '06 - 3:51 
Hi,
 
Here i my code:
 
BYTE pPort;
// Writes 0000 0001 to pin0 of the parallel port
Outportb((WORD) PARALLEL_PORT, (BYTE) 0x04);
// Wait here for the HW be ready
Sleep(2000);
pPort = (BYTE) Inportb((WORD) PARALLEL_PORT);
 
The problem I face is that, I give 4.5V to pin 4 (bit 3) of the PC. And I want to read it. But if I had written to that bit beforehands (I do this to be sure that I am resetting it, and reading the value from outside (that 4.5V I give from outside). What are your comments?
QuestionErrors????memberdSolariuM29 Jul '06 - 0:57 
Hi,
Very good,
But when I want to compile and run your project ,it gives me error.
And also when I add a DDK header (like video video.h) it gives me 92 errors.
please help me about using ddk in MFC. I need it.
Thank you.
 
Every new thing you learn,Gives you a new personality.

GeneralPower ManagermemberAhtsair Lin9 Oct '05 - 3:57 
Beause I can't get outport status, I just memorize the outport value in memory, after restarted from hibernate, I want to reset the hardware to original outport value, what I should to ? Thanks a lot!
GeneralVC 6.0 versionmemberLee Middleotn6 Apr '05 - 14:39 
Could you please supply a version for Visual Studio 6.0? and perhaps a little more information in your article?
 
Thanks,
GeneralRe: VC 6.0 versionmemberAndre12347 Apr '05 - 1:14 
Me two please! Smile | :)
GeneralRe: VC 6.0 versionmemberXor2567 Apr '05 - 10:53 
yes, I send version VC6 to codeproject.Big Grin | :-D

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 6 Apr 2005
Article Copyright 2005 by Guerino Palacios
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid