procedure SynAPP(App:THandle );stdcall; begin Application.Initialize; Application.Handle := App; end;
procedure ShowForm;stdcall; begin try frmDLL := TfrmDLL.Create (Application); frmDLL.ShowModal = idOk ; except on E: Exception do MessageDlg ('Error in DLLForm: ' + E.Message, mtError, [mbOK], 0); end; end;
procedure TFrmDll.ComPort1RxChar(Sender: TObject; Count: Integer); var ss:string; begin ComPort1.ReadStr(ss,Count); Edit1.Text:='RxChar'; flag:=true; end;
function TFrmDll.IntFuction:boolean; begin Result:=false; flag:=false; ComPort1.WriteStr('asdfgh'); Repeat Application.ProcessMessages; ////////////////////////////////////// until flag=true; Edit1.Text:='已经反馈lllll'; Result:=true; end;
procedure TFrmDll.Button2Click(Sender: TObject); begin IntFuction; end;
function TFrmDll.IntFuction:boolean; var passtime:cardinal; begin Result:=false; flag:=false; ComPort1.WriteStr('asdfgh'); passtime:=gettickcount; Repeat Application.ProcessMessages; ////////////////////////////////////// //until flag=true; until gettickcount-passtime>1000;//在这儿最多延时一秒; if flag then//换成这样试试吧,我没有调试,你自己再试试; begin Edit1.Text:='已经反馈lllll'; Result:=true; end; end;