• Advertisement
Sign in to follow this  

[.net] Continued problems with LPT1

This topic is 3225 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Is there a reason you can't use the System.Printing namespace for this?

edit - Nevermind. I just read your other post.

Share this post


Link to post
Share on other sites
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);
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement