使用Socket服务进行“来电显示”二次开发 |
chen在2006/6/11发表,被浏览7498次
|
编程方式:delphi 查询和获取来电信息的Socket的指令见“服务程序”一文。 建立窗体如下:
程序代码如下: unit cltTeleSS; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ScktComp; type TForm1 = class(TForm) edCmd: TEdit; Button1: TButton; ClientSocket1: TClientSocket; Memo1: TMemo; edIP: TEdit; Button2: TButton; edPort: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; procedure Button1Click(Sender: TObject); procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket); procedure FormShow(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormShow(Sender: TObject); begin //ClientSocket1.Active:=True; end; procedure TForm1.Button1Click(Sender: TObject); begin ClientSocket1.Socket.SendText(edCmd.Text); end; procedure TForm1.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket); begin Memo1.Lines.Add(Socket.ReceiveText); end; procedure TForm1.Button2Click(Sender: TObject); begin with ClientSocket1 do begin if Active then Close; Address:=edIP.Text; Port:=StrToInt(edPort.Text); Active:=True; end; end; end.
|
|
|
|