运行至A点,lDeviceType, lBaud都被赋值了,但是至B点取不到
看watchlist窗口说是由于优化无法读取了>.<现在偶用的笨办法是声明全局变量>.<procedure TForm1.Button1Click(Sender: TObject);
var
lDeviceType, lBaud, comstate: Longint;
begin
lDeviceType := ComboBox2.ItemIndex;
lPort := ComboBox1.ItemIndex + 1;
case ComboBox3.ItemIndex of
0:
  lBaud := 9600;
1:
  lBaud := 38400;
2:
  lBaud := 57600;
3:
  lBaud := 152000;                       ///A
end;comstate := MITOpenComm(lDeviceType, 0, lPort, lBaud, 15); ///B
case comstate of
0:
  Application.MessageBox('初始化成功', 'MITSMS', MB_OK);
-1:
  Application.MessageBox('连接串口失败', 'MITSMS', MB_OK);
-2:
  Application.MessageBox('初始化红外连接错误', 'MITSMS', MB_OK);
-3:
  Application.MessageBox('检测不到设备', 'MITSMS', MB_OK);
-4:
  Application.MessageBox('加密狗错误', 'MITSMS', MB_OK);
end;end;