Posted by Maxwell on June 16, 2005 In Reply to: Reading input from ports with Delphi posted by zmo on June 09, 2005 : I want to know how can read datas from ports (LPT, ...). It's for data acquisition. I alread think for this in (LPT ports), but i don't know it is right or not. It's in the following: : var port:array[0..65536]of byte; : const data=$378; With the arrival of the Windows NT, Windows 2000 and Windows XP, accessing a port became complicated. There are 2 modes, kernel mode and user mode: Solution: use a driver that runs in kernel mode, and access this driver in user mode. Luckily, somebody has already developed such a DLL for the ports, have a look at: You have to link the functions of the DLL to your application. Add these two lines of code to the implementation part: function Inp32(wAddr: word): byte; stdcall; external 'inpout32.dll'; function Out32(wAddr: word; bOut: byte): byte; stdcall; external 'inpout32.dll';Later, use the functions, for example: { Send 65 to port 378 } Out32($378,65); { Read port 378 } ShowMessage('Port $378:'+ IntToStr(Inp32($378)));
|
|