調用的dll為inpout32.dll---操作並口錯誤如下:
SEHException External component has thrown an exception 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);
} private void button2_Click(object sender, EventArgs e)
{
int m= PortAccess.Input(888);//从888(即0x378)端口读取数据
this.textBox1.Text = m.ToString();
} private void button1_Click(object sender, EventArgs e)
{
//int m = Convert.ToInt32(this.textBox2.Text.Trim());
PortAccess.Output(888, 4);//把4从888端口输出
}
謝謝!
Output(int adress, int value);
Input(int adress);
中的adress的类型应该是byte型才对
它的位置放在程序下了吗?
用它已经用了几年了没问题啊。