C#并口操作

using System;
using System.Runtime.InteropServices;
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); 
}

//Output函数为给端口传送数据,Input是从端口读取数据 如:

           PortAccess.Input( 888 );//从888(即0x378)端口读取数据

           PortAccess.Output( 888, 4 )//把4从888端口输出

原文地址:https://www.cnblogs.com/qqhfeng/p/3645754.html