⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 Components for Delphi for work with phones Motorola.
💻 PAS
字号:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, MotoMMCMode;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Button3: TButton;
    Label3: TLabel;
    GroupBox5: TGroupBox;
    Memo3: TMemo;
    MotoMMCMode1: TMotoMMCMode;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    GroupBox4: TGroupBox;
    Memo2: TMemo;
    Button7: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure MotoMMCMode1Debug(const AItem: TMotoMMCModemItem;
      const ADebugText: String; const ADebugType: TDebugType;
      const ASubError: Boolean);
    procedure MotoMMCMode1Arrival(Sender: TObject);
    procedure MotoMMCMode1Remove(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure AddDebug(AText:string);
begin
 Form1.Memo3.Lines.Append(AText);
end;

procedure GetDevises;
var i   : integer;
    Dev : TMotoMMCModemItem;
begin
 with Form1 do begin
  ListBox1.Clear;
  MotoMMCMode1.DeviceList.Update;
  for i:=0 to MotoMMCMode1.DeviceList.Count-1 do begin
   Dev := MotoMMCMode1.DeviceList.Items[i];
   if Dev=nil then continue;
   ListBox1.Items.Add(Dev.ModemInfo.ClassDescr);
  end;
  AddDebug(Format('I Found Phone MMC Mode count: %d',[MotoMMCMode1.DeviceList.Count]));
 end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 GetDevises;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 GetDevises;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var item : TMotoMMCModemItem;
begin
 Label3.Caption := '';
 Memo1.Lines.Clear;
 Label2.Caption := 'DisConnect';
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 // Get
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
  // Info
  with item.ModemInfo do begin
   Memo1.Lines.Add(Format('DeviceID %d',[DeviceID]));
   Memo1.Lines.Add(Format('DevicePath %s',[DevicePath]));
   Memo1.Lines.Add(Format('Capabilities %d',[Capabilities]));
   Memo1.Lines.Add(Format('ClassDescr %s',[ClassDescr]));
   Memo1.Lines.Add(Format('ClassGUID %s',[ClassGUID]));
   Memo1.Lines.Add(Format('CompatibleIDs %s',[CompatibleIDs]));
   Memo1.Lines.Add(Format('ConfigFlags %d',[ConfigFlags]));
   Memo1.Lines.Add(Format('LowerFilters %s',[LowerFilters]));
   Memo1.Lines.Add(Format('Mfg %s',[Mfg]));
   Memo1.Lines.Add(Format('UpperFilters %s',[UpperFilters]));
   Memo1.Lines.Add(Format('Address %s',[Address]));
   Memo1.Lines.Add(Format('BusNumber %d',[BusNumber]));
   Memo1.Lines.Add(Format('Driver %s',[Driver]));
   Memo1.Lines.Add(Format('BusType %s',[BusType]));
   Memo1.Lines.Add(Format('Characteristics %s',[Characteristics]));
   Memo1.Lines.Add(Format('DevType %s',[DevType]));
   Memo1.Lines.Add(Format('Exclusive %d',[Exclusive]));
   Memo1.Lines.Add(Format('LegacyBusType %s',[LegacyBusType]));
   Memo1.Lines.Add(Format('LocationInfo %s',[LocationInfo]));
   Memo1.Lines.Add(Format('PhysDevObjName %s',[PhysDevObjName]));
   Memo1.Lines.Add(Format('Security %s',[Security]));
   Memo1.Lines.Add(Format('Service %s',[Service]));
   Memo1.Lines.Add(Format('UINumber %d',[UINumber]));
   Memo1.Lines.Add(Format('UINumberFormat %s',[UINumberFormat]));
  end;
  // Status
  if item.IsOpened then
   Label2.Caption := 'Connect'
  else
   Label2.Caption := 'DisConnect';
end;

procedure TForm1.Button2Click(Sender: TObject);
var item : TMotoMMCModemItem;
begin
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
 item.Open;
 ListBox1.OnClick(nil);
end;

procedure TForm1.Button3Click(Sender: TObject);
var item : TMotoMMCModemItem;
begin
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
 item.Close;
 ListBox1.OnClick(nil);
end;

procedure TForm1.FormDestroy(Sender: TObject);
var i:integer;
begin
 for i:=0 to MotoMMCMode1.DeviceList.Count-1 do
  if MotoMMCMode1.DeviceList.items[i].IsOpened then
    MotoMMCMode1.DeviceList.items[i].Close
end;

procedure TForm1.MotoMMCMode1Debug(const AItem: TMotoMMCModemItem;
  const ADebugText: String; const ADebugType: TDebugType;
  const ASubError: Boolean);
var S:string;
begin
 if ADebugType=dtError then
  S := '[E] '
 else
  S := '[I] ';
 if ASubError then
  S := S+' + ';
 S := S + ADebugText;
 AddDebug(S);
end;

procedure TForm1.MotoMMCMode1Arrival(Sender: TObject);
begin
 GetDevises;
 AddDebug('I Phone MMC Mode Arrival');
end;

procedure TForm1.MotoMMCMode1Remove(Sender: TObject);
begin
 GetDevises;
 AddDebug('I Phone MMC Mode Remove');
end;

procedure TForm1.Button4Click(Sender: TObject);
var item : TMotoMMCModemItem;
begin
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
 item.Switch(cmsAT);
 ListBox1.OnClick(nil);
end;

procedure TForm1.Button5Click(Sender: TObject);
var item : TMotoMMCModemItem;
begin
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
 item.Switch(cmsP2K);
 ListBox1.OnClick(nil);
end;

procedure TForm1.Button6Click(Sender: TObject);
var item : TMotoMMCModemItem;
    info : TDiskInformation;
    S    : string;
begin
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
 item.GetDiskInformation(info);
 Memo2.Clear;
 Memo2.Lines.Add(Format('Cylinders: %d',[info.Cylinders.QuadPart]));
 Memo2.Lines.Add(Format('TracksPerCylinder: %d',[info.TracksPerCylinder]));
 Memo2.Lines.Add(Format('SectorsPerTrack: %d',[info.SectorsPerTrack]));
 Memo2.Lines.Add(Format('BytesPerSector: %2.f 炅',[info.BytesPerSector/1024]));
 case info.MediaType of
    F5_1Pt2_512  : S :='5.25", 1.2MB,  512 bytes/sector';
    F3_1Pt44_512 : S :='3.5",  1.44MB, 512 bytes/sector';    F3_2Pt88_512 : S :='3.5",  2.88MB, 512 bytes/sector';    F3_20Pt8_512 : S :='3.5",  20.8MB, 512 bytes/sector';    F3_720_512   : S :='3.5",  720KB,  512 bytes/sector';    F5_360_512   : S :='5.25", 360KB,  512 bytes/sector';    F5_320_512   : S :='5.25", 320KB,  512 bytes/sector';    F5_320_1024  : S :='5.25", 320KB,  1024 bytes/sector';    F5_180_512   : S :='5.25", 180KB,  512 bytes/sector';    F5_160_512   : S :='5.25", 160KB,  512 bytes/sector';    RemovableMedia : S :='Removable media other than floppy';    FixedMedia     : S :='Fixed hard disk media';    F3_120M_512    : S :='3.5", 120M Floppy';    F3_640_512     : S :='3.5" ,  640KB,  512 bytes/sector';    F5_640_512     : S :='5.25",  640KB,  512 bytes/sector';    F5_720_512     : S :='5.25",  720KB,  512 bytes/sector';    F3_1Pt2_512    : S :='3.5" ,  1.2Mb,  512 bytes/sector';    F3_1Pt23_1024  : S :='3.5" ,  1.23Mb, 1024 bytes/sector';    F5_1Pt23_1024  : S :='5.25",  1.23MB, 1024 bytes/sector';    F3_128Mb_512   : S :='3.5" MO 128Mb   512 bytes/sector';    F3_230Mb_512   : S :='3.5" MO 230Mb   512 bytes/sector';    F8_256_128     : S :='8",     256KB,  128 bytes/sector';    F3_200Mb_512   : S :='3.5",   200M Floppy (HiFD)';    F3_240M_512    : S :='3.5",   240Mb Floppy (HiFD)';    F3_32M_512     : S :='3.5",   32Mb Floppy';
     else S := 'Unknown';
 end;
 Memo2.Lines.Add(Format('Media Type: %s',[S]));
 ListBox1.OnClick(nil);
end;

procedure TForm1.Button7Click(Sender: TObject);
var item : TMotoMMCModemItem;
    info : TDiskNumber;
begin
 if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
 item := MotoMMCMode1.DeviceList.Items[ListBox1.ItemIndex];
 if item=nil then exit;
 item.GetDiskNumber(info);
 Memo2.Clear;

 Memo2.Lines.Add(Format('Devise Type: %d',[info.DeviceType]));
 Memo2.Lines.Add(Format('Device Number: %d',[info.DeviceNumber]));
 Memo2.Lines.Add(Format('Partition Number: %d',[info.PartitionNumber]));

 ListBox1.OnClick(nil);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -