Read Imei Pin Mep BlackBerry Complete Source


unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ActiveX, StdCtrls, RIMRADIOCOMLib_TLB, Buttons;
type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  i: Cardinal;
  SwPartList: IGetSwPartList;
  PartList: PSafeArray;
  RRO: TRIMRadioObj;
  Connection: IConnection;
  IMEI: IReadIMEI;
  StrImei: WideString;
  pl: WideString;
  BBPIN: IReadBBPIN;
  edtClipBoard: TEdit;
begin
  // Create RIM Radio Object
  RRO := TRIMRadioObj.Create(Form1);
  // Query different interfaces to see if are supported
  // if OK then read desired information
  if RRO.DefaultInterface.QueryInterface(IID_IConnection, Connection) = S_OK then
  begin
    // Connect to phone
    Connection.Connect('USB', 300, 19200, '');
    // Read BBPIN
    if (Connection.IsConnected = 1) and (RRO.DefaultInterface.QueryInterface(IID_IReadBBPIN, BBPIN) = S_OK) then
    begin
      // Use IntToHex(BBPIN.Execute,6) to show BBPIN
      Edit3.Text := IntToHex(BBPIN.Execute,6);
    end;
    // IMEI
    if (Connection.IsConnected = 1) and (RRO.DefaultInterface.QueryInterface(IID_IReadIMEI, IMEI) = S_OK) then
    begin
      IMEI.Execute(StrImei);
      Edit1.Text := StringReplace(StrImei, '/', '', [rfReplaceAll]);
    end;
    // PartList
    if (Connection.IsConnected = 1) and (RRO.DefaultInterface.QueryInterface(IID_IGetSwPartList, SwPartList) = S_OK) then
    begin
      SwPartList.Execute(PartList);
      for i:=0 to PartList.rgsabound[0].cElements-1 do
      begin
         SafeArrayGetElement(PartList, i, pl);
         // From all partlist info just show MEP
         if Pos('MEP', pl) > 0  then
           Edit2.Text := pl;
      end;
    end;
    // Create a TEdit to put IMEI + MEP together and paste it to clipboard
    edtClipBoard := TEdit.Create(Form1);
    edtClipBoard.Parent := Form1;
    edtClipBoard.Text := 'IMEI:' + Edit1.Text + ' MEP:' + Edit2.Text;
    edtClipBoard.SelectAll;
    edtClipBoard.CopyToClipboard;
    edtClipBoard.Free;
    // Finish then disconnect interface
    Connection.Disconnect;
  end;
  // Release Rim Radio Object
  RRO.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:='';  Edit2.Text:='';  Edit3.Text:='';
end;
end.

0 comments:

Post a Comment

◄ Newer Post Older Post ►
 

Copyright © 2012. Gsm Library - All Rights Reserved K-Theme by Vinno