Click to See Complete Forum and Search --> : parallel port


July 12th, 2000, 01:39 PM
Anyone have any tips on how to access the parallel port in C code - i'm thinking using outp at some address, but i don't know the address of the parallel port. is all the data i need for accessing it in the device manager on my control panel? and finally, how can i access the port directly?

thanks

P_Aybara
July 12th, 2000, 03:09 PM
You're in the wrong message board, but if you do a CreateFile and pass in the file name "COM1" you can open a com port. I'd assume passing in "LPT1" would open that port as well.

WillemM
October 5th, 2002, 01:53 AM
Sorry, I can't help you at the moment but I am working on a comport wrapper/driver. Due to some problems in the .NET code it's not possible for me to give you the files you need.
I will look also for a wrapper around the COM code for the parallel port.

Anders Jansson
February 11th, 2004, 04:22 AM
Has anyone become any wiser regarding this subject?


This is something I have used in c++ but how can I use api functions like CreateFile in c#?

Maybe there is a better way?

All help appretiated.


s2 = "Kalle";
s = "LPT1";
h = CreateFile(s,GENERIC_WRITE or
GENERIC_READ,0,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if (h = INVALID_HANDLE_VALUE)
{
b= false;
}

b = WriteFile(h,s2 ,5,written,nil);
CloseHandle(h);

WillemM
February 11th, 2004, 09:33 AM
[DllImport("kernel32.dll")]
public external int CreateFile(.......)


The DllImport Attribute can be used to import API functions from other COM Dll files and Win32 dll files. So this can also be used to import windows API Functions into C#.