在 Windows 7 中写入并行端口
我需要在我的 C# 代码中通过并行端口输出 8 位数据。我使用的是 Windows7 Ultimate,并且有一个 Intel 945GCNL 主板,该主板具有并行端口并配置为地址 0378-037F。端口被初始化到内核(启动时所有引脚 D0-D7 均为高电平)。即使使用下面给出的代码后我也无法写出数据。
using System;
using System.Runtime.InteropServices;
public class PortAccess
{
[DllImport("inpout32.dll", EntryPoint="Out32")]
public static extern void Output(int adress, int value);
}
我尝试使用 codeproject 上提供的代码,尽管该程序没有生成任何错误,但我无法观察到任何输出。我什至在system32文件夹中安装了inpout32.dll。下面给出了将十六进制值输出到并行端口的代码部分。
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;
}
所有数据引脚都保持高电平并且无法控制它们。请帮忙。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论