[.net] Continued problems with LPT1

Started by
3 comments, last by Dave Hunt 14 years, 11 months ago
I'm back at this problem which I posted a few weeks back. I'm trying to open LPT1 for printing (actualli I just want to get bits out of it) in my GameDev C# program. I have a USB to parallel cable connected to my computer which works. I can print to it. When I open for printing in my program with the following statement I get a null (-1) pointer. Can anybody help? IntPtr ptr = CreateFile("LPT1", GENERIC_WRITE, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
Advertisement
What do you mean by "I just want to get bits out of it"? If you mean get/set the state of pins on the port, then it is very unlikely that you will be able to with a USB printer adapter.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Is there a reason you can't use the System.Printing namespace for this?

edit - Nevermind. I just read your other post.
FYI There is also a method of reading/writing to parallel ports using Inpout32.dll. I'm not sure if it would work with a USB to parallel adapter though.

class LPT{	[DllImport("inpout32.dll")]	public static extern void Out32(int address, int value);	[DllImport("inpout32.dll")]	public static extern int Inp32(int address);}
I'm a bit confused. Do you have a parallel printer hooked up to a USB port with a converter cable? Or do you have a USB printer hooked up to a parallel port with a converter cable?

If it's the former, then what you are trying won't work because you don't actually have a parallel port.

If it's the latter, it may work, but there is no guarantee that what you send is what you get because of the signal conversion.

This topic is closed to new replies.

Advertisement