VB programming how to control IO port

zhaozj2021-02-11  181

VB programming how to control I / O port

Http://www.tongyi.net Source: Netease Click: 744

VB does not provide a method of reading and writing I / O ports. So you can only write DLL with other languages, then call in VB. If you use C / C under Windows, then there may be no difficulty in writing such a DLL. Inputs in C, including INP and OUTP functions. You can build the following C language code (32-bit) to generate a DLL and then call in VB. The code is as follows: #include #include / * role: read a byte parameter from the specified port: portid port number Return value: read byte * / int _stdcall inport (short portid) {Return INP (portid);} / * Run: Write a byte parameter to the specified port: portid port number * / void _stdcall output (shortte) {OUTP (portid, byte);} / * role: read a byte parameter from the specified port : Portid port number Return Value: Read byte * / int _stdcall inportw (short portid) {return INPW (portid);} / * role: Write a byte parameter to the specified port: portid port number * / void _stdcall OUTPORTW (Short Portid, Short Word) {OUTPW (unsigned short);} Note: This method can only be used for Windows 95, can not be used for Windows NT

转载请注明原文地址:https://www.9cbs.com/read-5445.html

New Post(0)