kku
January 20th, 2006, 01:29 PM
hi,
i want to write data on printer port ,have any cammand that do that.
the data may be 0 or 1
Thanx
i want to write data on printer port ,have any cammand that do that.
the data may be 0 or 1
Thanx
|
Click to See Complete Forum and Search --> : write data on LPT Port using win32 kku January 20th, 2006, 01:29 PM hi, i want to write data on printer port ,have any cammand that do that. the data may be 0 or 1 Thanx NoHero January 20th, 2006, 01:46 PM Use CreateFile (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfile.asp) to open your LPT device as described under communication resources (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resources.asp). Instead of "COM1" just open "LPT1". If you have any further questions, feel free to ask again. ;) eeboy January 21st, 2006, 04:43 AM Does CreateFile work with NT,2000,XP? sreehari January 21st, 2006, 08:20 AM Does CreateFile work with NT,2000,XP? yep it does regards sreehari leojose January 21st, 2006, 09:07 AM Does CreateFile work with NT,2000,XP? To know what operating systems are supported by an api, look under the Requirements section of that api in MSDN. CreateFile (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/createfile.asp) kku January 21st, 2006, 01:02 PM Actually i want to write bit on printer port pin.i has been done it in delphi,if we write 1 on a pin then it show high voltage and 0 for low,i just need a simple code that how i can write data in a printer port on any PIN, In simple C we use outportb(port NO,value); can it work for my this problem in vc++. I m using XP and Tool VC++ 6.0 golanshahar January 21st, 2006, 01:10 PM can it work for my this problem in vc++. Your question is not clear :confused: you have been told above how to do it, you can also look at this article: Using standard printing from windows (http://www.codeguru.com/Cpp/W-P/printing/article.php/c2949/) please be more specific. Cheers eeboy January 21st, 2006, 05:33 PM I know CreateFile will work under NT,2000,XP but if you try to obtain a handle and access the port don't you generate an exception? It's been a while but as I recall you get a priviliged instruction exception. Not true? golanshahar January 22nd, 2006, 03:12 AM I know CreateFile will work under NT,2000,XP but if you try to obtain a handle and access the port don't you generate an exception? It's been a while but as I recall you get a priviliged instruction exception. Not true? First ::CreateFile(..) will work in win95 and higher you can refer to msdn for more info, look at leojose post. Now to your question about exception, why do you think you will get exception if you try open that port via ::CreateFile(..) ? :confused: Did you try it and get exception? You should check the handle you get and if its INVALID_HANDLE_VALUE you can use ::GetLastError() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/getlasterror.asp) for more info about the failure. Cheers codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |