在RS232中有4个脚位可用来回应讯号给电脑分別为CTS,DSR,RING,RLSD当未接上设备时,脚位的电太皆为低电压,讯号传回OFF,很多设备都利用此四个脚位与电脑沟通,所以检查脚位电压就知道改COM上是否有设备存在
MS_CTS_ON,MS_DSR_ON,MS_RING_ON,MS_RLSD_ON
procedure TForm1.Button1Click(Sender: TObject);
var
cc:TCommConfig;
hComm:THandle;
Com:String;
lS:dword;
begin
Com:='COM2';
hComm:=CreateFile(Pchar(Com),Generic_read or Generic_write,0,nil,open_existing,0,0);
if GetCommModemStatus(hcomm,lS) then
begin
if(ls and MS_CTS_ON)=MS_CTS_ON then
begi...[ 查看全文 ]