Write to parallel port in Windows 7

5k views Asked by At

I need to output 8 bit data through parallel port in my C# code. I am using Windows7 Ultimate and have a Intel 945GCNL motherboard which has a parallel port and configured to address 0378-037F. The port is initialized to the kernel (on start up all the pins D0-D7 are high). I am not able to write data out even after using the code given below.

using System;
using System.Runtime.InteropServices;

public class PortAccess
{
    [DllImport("inpout32.dll", EntryPoint="Out32")]
    public static extern void Output(int adress, int value);
}

I tried using this code available at codeproject, although the program is not generating any errors I am not able to observe any output. I even installed inpout32.dll in system32 folder. The part of the code which outputs the hex value to parallel port is given below.

switch(j)
                {
                    case 0:
                        PortAccess.Output(888, 24);
                        break;
                    case 1:
                        PortAccess.Output(888, 36);
                        break;
                    case 2:
                        PortAccess.Output(888, 66);
                        break;
                    case 3:
                        PortAccess.Output(888, 129);
                        break;
                    case 4:
                        PortAccess.Output(888, 0);
                        break;
                    case 5:
                        PortAccess.Output(888, 129);
                        break;
                    case 6:
                        PortAccess.Output(888, 195);
                        break;
                    case 7:
                        PortAccess.Output(888, 231);
                        break;
                    case 8:
                        PortAccess.Output(888, 255);
                        break;
                }

All the data pins stay high and there is no way to control them. Please help.

0

There are 0 answers