-
Mar 11th, 2011, 02:31 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Writing to parallel port - Windows 7 64-bit
Does anyone have experience writing data to the parallel port (printer port) in Windows 7 64-bit. I have been trying inpout32.dll, inpoutx64.dll and following all the info on http://www.highrez.co.uk/ and www.logix4u.net but can't get anything to work. I have an on-board parallel port at &H378 - not an add-on card - and have tried various modes in the BIOS (standard, ECP etc). I have a background in electronics so I am confident my testing methods are sound; I just cannot get a data bit to change state under program control. I need to send data to an 8-bit port on some 20th Century electronics so serial/USB interfaces are not really an option. There must be a way to control those 8 data bits in Windows 7, mustn't there?
Thanks in advance.
-
Mar 11th, 2011, 03:21 PM
#2
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Windows is supposed to be a "protected operating system" which means that no process running at the application layer is (supposed to be) allowed to 'talk' directly to hardware. Only processes at the driver layer are allowed to do that.
I said "Supposed to be" because Windows9x was not strict about that and I believe even the inpout dlls appeared to work ok with w2000 and XP. But maybe Windows 7 finally closed that door.
Have you tried simply copying data to the 'file' called LPT1.
Last edited by IanS; Mar 11th, 2011 at 03:24 PM.
-
Mar 11th, 2011, 03:25 PM
#3
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by IanS
Windows is supposed to be a "protected operating system" which means that no process running at the application layer is allowed to 'talk' directly to hardware. Only processes at the driver layer are allowed to do that.
However, Windows9x was not strict about that and I believe even the inpout dlls appeared to work ok with windows XP. But maybe Windows7 finally closed the door.
Have you tried simply copying data to the 'file' called LPT1
Thanks for your reply. How do you copy data to LPT1?
EDIT: Guess you mean something like copy test.txt lpt1 at a command prompt? I guess it could work once I connect the device and the handshaking lines. Difficult to set up the hardware for test purposes though.
Last edited by paulg4ije; Mar 11th, 2011 at 03:34 PM.
-
Mar 11th, 2011, 03:36 PM
#4
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Deep down in the operating system there are files called LPT1, LPT2, Com1, Com2 etc.
You can read and write to those 'files' exactly the same as you would read and write to any text file except that if you write data to a file called LPT1 then that data gets pushed out of IO port 378 (The parallel port). If you write to a file called LPT2 then the data goes out through 278
-
Mar 11th, 2011, 03:40 PM
#5
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
I haven't tested this so please check the syntax but something like this 'might' work
Code:
Dim FILE_NAME As String = "LPT1"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write("SOME TEXT")
objWriter.Close()
MsgBox("Text written to port")
Else
MsgBox("Port Does Not Exist")
End If
-
Mar 11th, 2011, 03:41 PM
#6
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Thanks Ian. I think there is some chance this could work, as I am effectively transferring a file and not looking to access individual data bits. I will have to make up a cable and test it when I next have access to the old hardware.
Last edited by paulg4ije; Mar 11th, 2011 at 03:46 PM.
-
Mar 11th, 2011, 04:48 PM
#7
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
I actually missed your last reply when I posed my last response. I get "Port does not exist" with your code but I will investigate this idea further.
Thanks for your help.
Last edited by paulg4ije; Mar 12th, 2011 at 03:29 AM.
-
Mar 12th, 2011, 03:31 AM
#8
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
I will leave this thread open in case there are more suggestions. If the simple file copy to LPT1 works, I will then want to move to the second stage, which is reading data INTO the parallel port.
Thanks.
-
Mar 12th, 2011, 10:11 AM
#9
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by paulg4ije
I will leave this thread open in case there are more suggestions. If the simple file copy to LPT1 works, I will then want to move to the second stage, which is reading data INTO the parallel port.
Thanks.
Take a look in device manager in the section "Ports Com&LPT". Do you have an entry for LPT1 ?
Because it's PCI it might be registered under a different port number. If LPT(n) exists in device manager then it's a kind of virtual file that you can write to. If it's a bi-directional port then you can also read from it just as if it was a file.
But maybe Windows7 has added some feature to stop us doing that kind of thing. : o (
Last edited by IanS; Mar 12th, 2011 at 10:18 AM.
-
Mar 12th, 2011, 01:16 PM
#10
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
I have Printer Port (LPT1) listed in Device Manager as expected. The address is &H378.
As you say, Windows 7 may have stopped us accessing the port. I have no trouble using inpout32.dll on a Windows XP machine.
-
Mar 12th, 2011, 03:36 PM
#11
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Just out of interest try to create a file on your desktop called LPT1
It shouldn't let you do that because LPT1 is a reserved name. It's a system filename that basically points pointing to the port.
If your Win7 machine allows you to create such a file then it indicates that LPT is not system wide as it was on 9x - XP. Maybe it's owned by the system and only exists in that 'users' space which is why you get the file not found message.
-
Mar 12th, 2011, 04:55 PM
#12
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
I get "This filename is reserved for use by Windows".
-
Mar 13th, 2011, 03:42 AM
#13
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
I finally got inpoutx64.dll working. My fault it took so long; I should learn to read the instructions
In case anyone else needs to write to their parallel port under Windows 7 64-bit, here's what you do:
Go to http://www.highrez.co.uk/downloads/inpout32/default.htm scroll down the page and click on the Binaries only - x86 & x64 DLLs and libs link. This will download InpOutBinaries_1500.zip. Once downloaded, unzip and go to the Win32 folder and double-click on InstallDriver.exe. You will get a UAC message asking if you want to allow the program to make changes. Answer Yes at your own risk ...
There is also a VB.NET test program on the highrez downloads page. Click on .NET 2.0 (2005) Example code to download it. It works fine in VB.NET 2010 Express.
To use the dll in your own programs, copy inpoutx64.dll into your debug folder. You will obviously need to distribute the dll with any published package you produce.
-
Apr 17th, 2011, 02:25 PM
#14
New Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by paulg4ije
I finally got inpoutx64.dll working. My fault it took so long; I should learn to read the instructions
In case anyone else needs to write to their parallel port under Windows 7 64-bit, here's what you do:
Go to http://www.highrez.co.uk/downloads/inpout32/default.htm scroll down the page and click on the Binaries only - x86 & x64 DLLs and libs link. This will download InpOutBinaries_1500.zip. Once downloaded, unzip and go to the Win32 folder and double-click on InstallDriver.exe. You will get a UAC message asking if you want to allow the program to make changes. Answer Yes at your own risk ...
There is also a VB.NET test program on the highrez downloads page. Click on .NET 2.0 (2005) Example code to download it. It works fine in VB.NET 2010 Express.
To use the dll in your own programs, copy inpoutx64.dll into your debug folder. You will obviously need to distribute the dll with any published package you produce.
Hi paulg4ije, I could not run inpoutx64.dll could explain and give an example of its use?
I need to write to the parallel port under windows 7 x64
Thanks!
-
Apr 18th, 2011, 02:29 AM
#15
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by soylachocha
Hi paulg4ije, I could not run inpoutx64.dll could explain and give an example of its use?
I need to write to the parallel port under windows 7 x64
Thanks!
My previous post describes the procedure quite well I think. Have you installed the driver as I said? Did you get an error when you clicked on "Installdriver.exe"? You must do this first or the DLL will not work. You must then put a copy of inpoutx64.dll in the \bin\x64\debug folder of your project, and distribute the dll with your installation package.
Last edited by paulg4ije; Apr 18th, 2011 at 02:33 AM.
-
Jul 20th, 2012, 03:05 AM
#16
New Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Hello,
I'm searching solution for this case - I have an application written in C and compiled with Labwindows/CVI, to communicate with parallel port;
it operates properly in 32bit, but in Win7 64 bit it cannot read/write via parallel port
I tried to follow all the instructions with inpoutx64.dll, but still it does not operate, maybe I'have missed smth?
best regards,
Armand
-
Jul 20th, 2012, 04:09 AM
#17
Thread Starter
Fanatic Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Originally Posted by armand2010
Hello,
I'm searching solution for this case - I have an application written in C and compiled with Labwindows/CVI, to communicate with parallel port;
it operates properly in 32bit, but in Win7 64 bit it cannot read/write via parallel port
I tried to follow all the instructions with inpoutx64.dll, but still it does not operate, maybe I'have missed smth?
best regards,
Armand
I don't know what else I can add really. You must follow the installation procedure exactly as I described it. Just copying the 64-bit DLL into your project will not work. The 32-bit DLL does work just by copying, but not the 64-bit version. Have you tried the .NET example code? Even if you don't normally use VB.NET or C# you could install one of those platforms just to prove the DLL is installed correctly. The example code works fine in VB.NET 2010 Express. I haven't tried C#.
Good luck!
-
Jul 20th, 2012, 04:11 AM
#18
New Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Thanks,
I'll try the .NET example code, I've not done it previously
Good luck!
-
Aug 2nd, 2012, 03:27 PM
#19
New Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
thanks a lot guys, thnks a lot paulg, thanks a lot highrez.co.uk... there is different world for who know english, if i do that with %10 english
-
Sep 18th, 2012, 09:27 PM
#20
New Member
Re: Writing to parallel port - Windows 7 64-bit
Hi paul4ije,
At first, thanks for your post.i can write to parallel port in win7 64 bits by using the way that you posted. But is it got the other way for us to read the data port?
Cause what i have done is just writing the 8bits data and "output" to data port, once i want to read from external circuit through data port, it always show "4" in decimal.
i am using Visual Basic 2008 and use the out() and inp() commands to access the data port. Anyone got idea about this?
Originally Posted by paulg4ije
I finally got inpoutx64.dll working. My fault it took so long; I should learn to read the instructions
In case anyone else needs to write to their parallel port under Windows 7 64-bit, here's what you do:
Go to http://www.highrez.co.uk/downloads/inpout32/default.htm scroll down the page and click on the Binaries only - x86 & x64 DLLs and libs link. This will download InpOutBinaries_1500.zip. Once downloaded, unzip and go to the Win32 folder and double-click on InstallDriver.exe. You will get a UAC message asking if you want to allow the program to make changes. Answer Yes at your own risk ...
There is also a VB.NET test program on the highrez downloads page. Click on .NET 2.0 (2005) Example code to download it. It works fine in VB.NET 2010 Express.
To use the dll in your own programs, copy inpoutx64.dll into your debug folder. You will obviously need to distribute the dll with any published package you produce.
-
Sep 19th, 2012, 02:42 AM
#21
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by ktwei
Hi paul4ije,
At first, thanks for your post.i can write to parallel port in win7 64 bits by using the way that you posted. But is it got the other way for us to read the data port?
Cause what i have done is just writing the 8bits data and "output" to data port, once i want to read from external circuit through data port, it always show "4" in decimal.
i am using Visual Basic 2008 and use the out() and inp() commands to access the data port. Anyone got idea about this?
I will check my code later and try to help you. I am just off to work now. My program uses reading from the port (input) just as much as output and it works very well.
EDIT: Just one quick thought: you need to set the data direction to input by setting bit 5 of the Control Port (890 or &37A in Hex) to logic 1 - something like Out64(890, 32).
Last edited by paulg4ije; Sep 19th, 2012 at 02:48 AM.
-
Sep 20th, 2012, 07:56 PM
#22
New Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by paulg4ije
I will check my code later and try to help you. I am just off to work now. My program uses reading from the port (input) just as much as output and it works very well.
EDIT: Just one quick thought: you need to set the data direction to input by setting bit 5 of the Control Port (890 or &37A in Hex) to logic 1 - something like Out64(890, 32).
i have solved the problem by changing the parallel port mode from SPP to EPP mode in win7 64bit. it works well. but i have try my code in winxp, it works well in SPP mode also.
-
Sep 21st, 2012, 06:10 AM
#23
Thread Starter
Fanatic Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Glad to hear you got it working
-
Sep 22nd, 2012, 09:12 AM
#24
New Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
[QUOTE=paulg4ije;4241309]Glad to hear you got it working [/Q
anyway, thank for ur help again.
-
Jul 17th, 2014, 10:08 AM
#25
New Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by paulg4ije
I finally got inpoutx64.dll working. My fault it took so long; I should learn to read the instructions
In case anyone else needs to write to their parallel port under Windows 7 64-bit, here's what you do:
Go to http://www.highrez.co.uk/downloads/inpout32/default.htm scroll down the page and click on the Binaries only - x86 & x64 DLLs and libs link. This will download InpOutBinaries_1500.zip. Once downloaded, unzip and go to the Win32 folder and double-click on InstallDriver.exe. You will get a UAC message asking if you want to allow the program to make changes. Answer Yes at your own risk ...
There is also a VB.NET test program on the highrez downloads page. Click on .NET 2.0 (2005) Example code to download it. It works fine in VB.NET 2010 Express.
To use the dll in your own programs, copy inpoutx64.dll into your debug folder. You will obviously need to distribute the dll with any published package you produce.
Do you know if something like this would work with Win7 32bit? I'm using VB6. the old inpout32.dll doesn't seem to work.
Thanks, ahab.
-
Jul 17th, 2014, 12:49 PM
#26
Thread Starter
Fanatic Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by ahab
Do you know if something like this would work with Win7 32bit? I'm using VB6. the old inpout32.dll doesn't seem to work.
Thanks, ahab.
I have only used the 64-bit version so I don't think I can be of any help. If I needed to use 32-bit I would just look at the documentation on the highrez.co.uk website.
Good luck with your project.
EDIT: Hmmm ... re-reading my posts it seems I must have used the 32-bit DLL but I don't remember doing anything special to make it work. I guess I just copied inpout32.dll into my project folder. Again, good luck!
Last edited by paulg4ije; Jul 17th, 2014 at 01:01 PM.
-
Jul 17th, 2014, 12:52 PM
#27
Banned
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Lol this is a really old and popular thread.
-
Jul 17th, 2014, 01:03 PM
#28
Thread Starter
Fanatic Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Indeed; old and popular - just like me
-
Jan 14th, 2015, 01:47 AM
#29
Registered User
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
Hi all,
I am working on the parallel port code in c#. I need the interrupt capability of the port.So have to write an ISR for the same.Is there any API to do the same?..how can i mapp the ISR function to the IRQ7 of the port?
-
May 7th, 2015, 07:10 PM
#30
New Member
Re: Writing to parallel port - Windows 7 64-bit
Originally Posted by paulg4ije
I finally got inpoutx64.dll working. My fault it took so long; I should learn to read the instructions
In case anyone else needs to write to their parallel port under Windows 7 64-bit, here's what you do:
Go to http://www.highrez.co.uk/downloads/inpout32/default.htm scroll down the page and click on the Binaries only - x86 & x64 DLLs and libs link. This will download InpOutBinaries_1500.zip. Once downloaded, unzip and go to the Win32 folder and double-click on InstallDriver.exe. You will get a UAC message asking if you want to allow the program to make changes. Answer Yes at your own risk ...
There is also a VB.NET test program on the highrez downloads page. Click on .NET 2.0 (2005) Example code to download it. It works fine in VB.NET 2010 Express.
To use the dll in your own programs, copy inpoutx64.dll into your debug folder. You will obviously need to distribute the dll with any published package you produce.
Paul, thank you for this post. Would you be able to share your vb code? I'm interested on knowing what you did.
-
May 8th, 2015, 07:41 AM
#31
Thread Starter
Fanatic Member
Re: [RESOLVED] Writing to parallel port - Windows 7 64-bit
My code is dedicated to specific tasks with a specific piece of hardware. I'm not sure how much of it will help you, but here are a few snippets:
Code:
' Put this in a module
<DllImport("InpOutx64.dll", CharSet:=CharSet.Auto, EntryPoint:="Inp32")> _
Function In64(ByVal PortAddress As Short) As Short
End Function
<DllImport("InpOutx64.dll", CharSet:=CharSet.Auto, EntryPoint:="Out32")> _
Sub Out64(ByVal PortAddress As Short, ByVal Data As Short)
End Sub
<DllImport("InpOutx64.dll", CharSet:=CharSet.Auto, EntryPoint:="IsInpOutDriverOpen")> _
Function IsInpOutDriverOpen_x64() As UInt32
End Function
Public GiDataPort As Short = 888 ' this is &378 in hex
Public GiStatusPort As Short = 889 ' this is &379 in hex
Public GiControlPort As Short = 890 ' this is &37A in hex
' End of module
' Sending data out of the parallel port
iStart = 12288 ' Start 16 picture lines from top
Call Send_Slow_Command_To_Robot(253) ' Send Field Write to Robot
For i As Integer = iStart To 196607
Do
Application.DoEvents()
Loop Until (In64(GiStatusPort) And 128) = 128
Out64(GiDataPort, GbyteData(iIndex)(i))
' Pulse STROBE low then high again
Out64(GiControlPort, 1)
Out64(GiControlPort, 0)
Next
' Reading data into the parallel port
Out64(GiControlPort, 34)
For i As Integer = 0 To Mbytes - 1
Out64(GiControlPort, 42)
Out64(GiControlPort, 34)
Do
Application.DoEvents()
Loop Until (In64(GiStatusPort) And 16) = 0
Mb(i) = In64(GiDataPort)
If i / iProgInc = i \ iProgInc Then
'Update progress bar every 1/20 of total bytes
pb_value += 5
If pb_value < 101 Then
prog1.Value = pb_value
End If
End If
Mi = i
Next i
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|