① Initialize():允许端口控制函数。在使用端口输入输出函数之前调用一次,成功返回“1”,失败返回“0”。
② Shutdown():关闭端口控制函数。在退出程序时执行一次,成功返回“1”,失败返回“0”。
③ GetPortVal(ByVal PortAddr As Integer, ByRef Portval As Long, ByVal bSize As Byte) As Boolean:读取端口函数,PortAddr 为端口地址, Portval为端口值,bSize为要读取的字节数。读取成功时返回“1”,失败时返回“0”。
④ SetPortVal(ByVal PortAddr As Integer, ByVal Portval As Long, ByVal bSize As Byte) As Boolean:写端口函数。PortAddr 为端口地址, Portval为要写的值,bSize为要写入的字节数。写入成功返回“1”,失败返回“0”。
四个函数在Winio.bas模块中的声明如下:
Declare FuncTIon IniTIalizeWinIo Lib “WinIo.dll” () As Boolean
Declare FuncTIon ShutdownWinIo Lib “WinIo.dll” () As Boolean
Declare Function GetPortVal Lib “WinIo.dll” (ByVal PortAddr As Integer, ByRef Portval As Long, ByVal bSize As Byte) As Boolean
Declare Function SetPortVal Lib “WinIo.dll” (ByVal PortAddr As Integer, ByVal Portval As Long, ByVal bSize As Byte) As Boolean