我记得api中可以检测串口是否打开,可我忘记了怎么写了,所以请都各位了。
我用的是delphi(分不够再加).
我用的是delphi(分不够再加).
解决方案 »
- 谁能给个好用的四舍五入函数?
- 无法捕捉错误,希望出错后关闭程序,该怎么做?
- 100分 :inno setup 中如何设置打包的程序为自动启动,或者为系统服务??
- 关于设计传递变量的问题
- 初学delphi 8 , 用BdpConnection1,连接MSSQL时出错
- mapx 关于查找最近的实体(如能解决500分赠送)
- 请问如何插入一个字段到SQLSERVER表中,如何写SQL语句?
- 如何動態創建一個表(ADO)??
- 再求李维的《Delphi 5.x 分布式多层应用系统篇》的随书代码!
- access violation at address 0050978C in module 'coreide70.bpl'. Read of address
- ToolBar与CoolBar有何区别?,如何禁止ToolBar在移动后被'X'掉?
- 为什么鼠标图标变不了?
这个语句怎么写呀,我现在急用。谢了
function OpenSB(Com,baud:integer):integer;
begin
hOilM:=CreateFile(pchar('COM'+inttostr(Com)),
GENERIC_READ or GENERIC_WRITE,
0,nil,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,0);
if hOilM = 0 then
begin
result:=-1;
exit;
end;
if (not BuildCommDCB(pchar('baud='+inttostr(baud)+' parity=N data=8 stop=1'),lpdcb)) then
begin
result:=-2;
exit;
end;
if (not SetCommState(hOilM,lpdcb)) then
begin
result:=-3;
exit;
end;
if (not GetCommTimeOuts(hOilM, Rs232timeout)) then
begin
result:=-4;
exit;
end;
Rs232TimeOut.ReadIntervalTimeout:=10;
Rs232TimeOut.ReadTotalTimeoutMultiplier:=1;
Rs232TimeOut.ReadTotalTimeoutConstant:=10;
if (not SetCommTimeOuts(hOilM,Rs232TimeOut)) then
begin
result:=-5;
exit;
end;
result:=0;
end;