Imported gammu 0.90.7
[gammu.git] / win32 / delphi7.gui / classic2 / Unit1.pas
blobdc6c9827a7aa8e6bc98c06a4858d461139b27b56
1 unit Unit1;
3 interface
5 uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, Gammu, ExtCtrls, ComCtrls;
9 type
10 TForm1 = class(TForm)
11 Edit1: TEdit;
12 Edit2: TEdit;
13 Label1: TLabel;
14 Label2: TLabel;
15 Edit3: TEdit;
16 Label3: TLabel;
17 Label4: TLabel;
18 Edit4: TEdit;
19 Button1: TButton;
20 Label5: TLabel;
21 Edit5: TEdit;
22 Label6: TLabel;
23 Edit6: TEdit;
24 procedure Button1Click(Sender: TObject);
25 private
26 { Private declarations }
27 PhoneID : integer;
28 PhoneCallBackPointer : PPhoneCallBackProc;
29 SecurityCallBackPointer : PSecurityCallBackProc;
30 SMSCallBackPointer : PSMSCallBackProc;
31 public
32 { Public declarations }
33 end;
35 var
36 Form1: TForm1;
38 implementation
40 {$R *.dfm}
42 //called, when phone is connected or disconnected
43 procedure ChangePhoneState1(x:integer;ID:integer;status:boolean);stdcall;
44 var
45 error: GSM_Error;
46 buffer : array[1..100] of char;
47 begin
48 if status then
49 begin
50 error:=GSM_GetDCT4SimlockNetwork(Form1.PhoneID,@buffer);
51 if (error <> GE_NONE) then application.MessageBox(pchar('Get simlock: error '+inttostr(integer(error))),'',0);
52 if (error = GE_NONE) then
53 begin
54 buffer[6]:=chr(0);
55 Form1.Edit3.Text:=buffer;
56 end;
58 error:=GSM_GetModelName(Form1.PhoneID,@buffer);
59 if (error = GE_NONE) then Form1.Edit5.Text:=buffer;
60 if (error <> GE_NONE) then application.MessageBox(pchar('Get model: error '+inttostr(integer(error))),'',0);
62 error:=GSM_GetIMEI(Form1.PhoneID,@buffer);
63 if (error <> GE_NONE) then application.MessageBox(pchar('Get IMEI: error '+inttostr(integer(error))),'',0);
64 if (error = GE_NONE) then Form1.Edit2.Text:=buffer;
66 error:=GSM_GetDCT4SecurityCode(Form1.PhoneID,@buffer);
67 if (error <> GE_NONE) then application.MessageBox(pchar('Get security code: error '+inttostr(integer(error))),'',0);
68 if (error = GE_NONE) then Form1.Edit6.Text:=buffer;
70 error:=GSM_EndConnection(Form1.PhoneID);
71 if (error <> GE_NONE) then application.MessageBox(pchar('End connection: error '+inttostr(integer(error))),'',0);
72 end;
73 end;
75 procedure TForm1.Button1Click(Sender: TObject);
76 var
77 Device: PChar;
78 Connection: PChar;
79 error: GSM_Error;
80 buffer : array[1..100] of char;
81 begin
82 GetMem(Device,Length(Edit4.Text) + 1);
83 StrCopy(Device, PChar(Edit4.Text));
85 GetMem(Connection,Length(Edit1.Text) + 1);
86 StrCopy(Connection, PChar(Edit1.Text));
88 PhoneCallBackPointer := @ChangePhoneState1;
89 SecurityCallBackPointer := nil;
90 SMSCallBackPointer := nil;
92 error:=GSM_StartConnection(@PhoneID,Device,Connection,'','','',@PhoneCallBackPointer,@SecurityCallBackPointer,@SMSCallBackPointer);
93 if (error<>GE_NONE) then application.MessageBox(pchar('Start: error '+inttostr(integer(error))),'',0);
95 FreeMem(Device);
96 FreeMem(Connection);
97 end;
99 end.