类定义: public class PortAccess //用于并口访问的类
{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
[DllImport("inpout32.dll", EntryPoint = "Inp32")]
public static extern int Input(int adress);
}
调用如下: try { while (PortAccess.Input(0x0378) == 0);}//等待来自并口数据线的触发信号
catch (Exception ex)
{
MessageBox.Show("并口错误!"+ex.Message,"错误");
}
serialPort1.WriteLine("s");
在调试运行的时候,总是提示“并口错误,外部组件发生异常”。
我检查了,自己的计算机设备管理器里面是可以看见并口的,驱动程序正常,端口范围0378 -- 037F
请大家帮忙看看。谢谢。
{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
[DllImport("inpout32.dll", EntryPoint = "Inp32")]
public static extern int Input(int adress);
}
调用如下: try { while (PortAccess.Input(0x0378) == 0);}//等待来自并口数据线的触发信号
catch (Exception ex)
{
MessageBox.Show("并口错误!"+ex.Message,"错误");
}
serialPort1.WriteLine("s");
在调试运行的时候,总是提示“并口错误,外部组件发生异常”。
我检查了,自己的计算机设备管理器里面是可以看见并口的,驱动程序正常,端口范围0378 -- 037F
请大家帮忙看看。谢谢。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货