![]() |
| | #1 |
| Imperator of Darkness Join Date: Jun 2008 Location: Detroit, MI
Posts: 38
| Question on Accessing parallel port I am trying to access parallel port with C++ on Windows XP. I already have inpout32.dll sitting in my Windows/system32 directory. The problem i encounter is that my complier BloodShed Dev C++ does not recognize inportb or outportb functions no matter what i include as a header. I need to know several things... 1) What functions should i use to access parallel port? and what header file to include? I do not want to use VC++ or Borland, most of the internet websites give examples on those compilers. I like using free compilers 2) How do i use inpout32.dll? Do i have to link to it in my code? if I do, how do I do it? or is it just fine sitiing where it is? 3) Can someone point me to a good resource that describes step by step how to access parrallel port in free compiler? |
| Luciferek is offline | |
| | #2 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| http://www.lvr.com/parport.htm > I do not want to use VC++ or Borland But that doesn't stop you using the win32 API, which DevC++ is perfectly capable of using. The link has examples of how to use the win32 API. > How do i use inpout32.dll? Since it seems to be a hack to get old inport() (aka DOS) programs to work, I would suggest you forget about it if you're just starting to learn this stuff. It's a quick fix now, but will cause serious problems later.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #3 |
| Imperator of Darkness Join Date: Jun 2008 Location: Detroit, MI
Posts: 38
| I was trying to find any info on using win 32 API funtions to access parallel port. Whole buch of crap and no specifics... On the link you provided there is an example for visual basic, i tried it and it gives me runtime error. Any link that would describe the API functions to access that damn port? |
| Luciferek is offline | |
| | #4 |
| Weak. Join Date: Apr 2005
Posts: 163
| Codeplug has a class based off the win32 api that helps you access the serial port found here: http://cboard.cprogramming.com/showp...52&postcount=4 BTW, just to make things clear Visual C++ Express Edition is free... |
| dra is offline | |
| | #5 |
| Registered User Join Date: Mar 2003
Posts: 3,844
| >> I was trying to find any info on using win 32 API funtions to access parallel port Define "access". Do you want pin-level control? Or you do you want to communicate with a IEEE-1284 device? For pin-level access, there isn't really a Win32 API for doing that - other than the MS-CRT functions _inp() and _outp(). MinGW uses the MS-CRT so these functions are available to you. The problem is that the "in" and "out" instructions are privileged under NT OS's. The inpout32 DLL provides two interfaces, Inp32() and Out32(), which somehow overcome this problem. Here's sample code that loads the library dynamically and uses those functions: http://www.hytherion.com/beattidp/comput/pport/Test1.c Another option (for pin-level access) is to use GiveIO or UserPort, which gives user-mode processes "permission" to use the "in" and "out" instructions - which mean you can use the MS-CRT functions: _inp() and _outp() (from conio.h). If you just want to communicate with a IEEE-1284 device, you can use CreateFile() on the dos-device name for the port, like "LPT1". Then use ReadFile() and WriteFile() normally. Or if you really want to keep is simple, you could try using standard stream I/O on the file "LPT1". >> On the link you provided there is an example for visual basic... There are a lot more resources than that when you use Salem's link as a starting point. gg |
| Codeplug is offline | |
| | #6 |
| Imperator of Darkness Join Date: Jun 2008 Location: Detroit, MI
Posts: 38
| All i want is to read and write to the 8 data pins on the parrallel port. However, it would be nice if i could control only one pin, instead of sending number value to drive those 8 pins. Two functions inp32() and out32() was what i needed to know in the first place.. now i'm cool Last edited by Luciferek; 06-16-2008 at 05:16 PM. |
| Luciferek is offline | |
| | #7 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| input to parallel port prob | tariq7868 | Tech Board | 4 | 06-11-2009 12:35 PM |
| Parallel Port: Sending the signals as binary | h3ro | Tech Board | 7 | 08-25-2007 12:22 PM |
| Parallel port programming | h3ro | Windows Programming | 6 | 08-08-2007 11:14 AM |
| programming the parallel port to control device | griffmaster2005 | C Programming | 3 | 02-14-2005 07:50 AM |
| Simple Parallel Port Control | BigSter | C++ Programming | 2 | 11-15-2001 10:51 PM |