贴段别人给我的程序,不一定正确, 参考一下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> OleCtrls, MSCommLib_TLB, StdCtrls, Buttons, ExtCtrls, ComCtrls, ImgList,<br> Db, ADODB, Menus, MPlayer;<br><br>type<br> TfmMain = class(TForm)<br> StatusBar: TStatusBar;<br> Panel1: TPanel;<br> Image1: TImage;<br> SpeedButton1: TSpeedButton;<br> MSC: TMSComm;<br> ImageList: TImageList;<br> ListView: TListView;<br> ADOTable1: TADOTable;<br> MediaPlayer: TMediaPlayer;<br> procedure MSCComm(Sender: TObject);<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> procedure SpeedButton1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> MessageStr:String;<br> end;<br>var<br> fmMain: TfmMain;<br>implementation<br>{$R *.DFM}<br>procedure TfmMain.MSCComm(Sender: TObject);<br>var<br> tempstr,SendCommand:string;<br> ee:char;<br>begin<br>// Application.MessageBox('有信息发送过来',Pchar('来电显'+Msc.Input),0);<br> MessageStr:=MessageStr+ Msc.Input;<br> ShowMessage( MessageStr);<br> if(Msc.CommEvent=comEvReceive) then<br> begin<br> tempstr:=Msc.Input;<br> tempstr:=trim(tempstr);<br> ShowMessage(tempstr);<br> StatusBar.Panels[0].Text:=tempstr;<br> if(AnsiUpperCase(tempStr)='RING') then<br> begin<br> StatusBar.Panels[0].Text:='有来电,请处理......';<br> MediaPlayer.FileName:='a.wav';<br> MediaPlayer.Open;<br> MediaPlayer.Play;<br> end;<br> end;<br>end;<br><br>procedure TfmMain.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> if MSC.PortOpen then<br> MSC.PortOpen:=false;<br>end;<br><br>procedure TfmMain.SpeedButton1Click(Sender: TObject);<br>begin<br> If MSC.PortOpen Then<br> MSC.PortOpen:= False;<br> MSC.CommPort:=1;<br> Msc.PortOpen:=true;<br> fmMain.Caption:='来电显示演示程序';<br> Msc.InputMode:=comInputModeText;<br>// MSC.Output:='AT#CID=1'+#13;<br>// MSC.Output:='AtS0=0'+#13;<br>end;<br>end.<br>