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

📄 unit1.pas

📁 boomerang library 5.11 internet ed
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  SM:= TSMvCard.Create;
  try
    SM.Records.Values['N']:= 'My test contact'; // name
    SM.Records.Values['TEL']:= '+420604123456'; // phone number
    SendSmartMessage(SM, smPortMIMEvCard);
  finally
    SM.Free;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  SM: TSMOperatorLogo;
  Bmp: TBitmap;
const
  OperatorID= 23001;  // T-Mobile Czech
begin
  SM:= TSMOperatorLogo.Create;
  try
    SM.Width:= 16;                // picture dimension
    SM.Height:= 16;
    SM.MCC:= OperatorID div 100;  // GSM operator network identifier
    SM.MNC:= OperatorID mod 100;
    Bmp:= TBitmap.Create;
    try
      Bmp.Monochrome:= True;
      Bmp.LoadFromFile('logo.bmp');  // bitmap mask
      SM.ImportFromImage(Bmp);
    finally
      Bmp.Free;
    end;
    SendSmartMessage(SM, smPortOperatorLogo);
  finally
    SM.Free;
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
var
  SndM: TSoundMelody;
  SM: TSMRingingTone;
  St: TStream;
begin
  SM:= TSMRingingTone.Create;
  try
    St:= TFileStream.Create('melody.rtt', fmOpenRead);
    try
      SndM:= TSoundMelody.Create;
      try
        SndM.RTTTL:= StreamToString(St);  // load from file in RTTTL format
        SM.AssignSoundMelody(SndM);
      finally
        SndM.Free;
      end;
    finally
      St.Free;
    end;
    SendSmartMessage(SM, smPortRingingTone);
  finally
    SM.Free;
  end;
end;

procedure TForm1.Button5Click(Sender: TObject);
var
  SMMP: TSMMultipartMessage;
  SM: TSMOTABitmap;
  SMT: TSMTextISO;
  Bmp: TBitmap;
begin
  SMMP:= TSMMultipartMessage.Create;
  try
    SM:= TSMOTABitmap.Create;     // picture
    SM.Width:= 16;                // picture dimension
    SM.Height:= 16;
    Bmp:= TBitmap.Create;
    try
      Bmp.Monochrome:= True;
      Bmp.LoadFromFile('logo.bmp');  // bitmap mask
      SM.ImportFromImage(Bmp);
    finally
      Bmp.Free;
    end;
    SMMP.Multiparts.Add(SM);      // add bitmap to multipart container

    SMT:= TSMTextISO.Create;      // additional text
    SMT.Text:= 'My first commented picture message';
    SMMP.Multiparts.Insert(0, SMT); // add text above picture

    SendSmartMessage(SMMP, smPortMultiPart);
  finally
    SMMP.Free;
  end;
end;

procedure TForm1.SendEMS(EMSObj: TEMSObject; aText: string);
var
  I: Integer;
  NBS: TUDHProtocol;
  EMS: TEMS;
  SMS: TSMSSubmit;
begin
  SMS:= TSMSSubmit.Create;
  try
    SMS.GSM:= GSM1;
    SMS.DA:= DestAddress;   // destination address
    SMS.DCS:= $F5;         // binary message, class 1
    SMS.UDHI:= True;       // user data header indicator
    NBS:= TEMSUDHProtocol.Create;
    try
      NBS.Options:= [smspoReference];
      NBS.Reference:= fReference mod 256;  // unique identifier
      Inc(fReference);         // every message has unique identifier
      EMS:= TEMS.Create;
      try
        EMS.Text:= aText;
        EMS.Objects.Add(EMSObj);  // add object to EMS container
        EMS.WriteTo(NBS);      // write data to protocol object
      finally
        EMS.Free;
      end;

      for I:= 1 to NBS.FragmentCount do   // send particular messages
      begin
        SMS.UD:= NBS.Fragments[I];
        GSM1.SendSMS(SMS);    // send message
      end;
    finally
      NBS.Free;
    end;
  finally
    SMS.Free;
  end;
end;

procedure TForm1.Button6Click(Sender: TObject);
var
  EMS: TEMSPicture;
  Bmp: TBitmap;
begin
  EMS:= TEMSPictureSmall.Create;  // 16x16 pixels
  Bmp:= TBitmap.Create;
  try
    Bmp.Monochrome:= True;
    Bmp.LoadFromFile('logo.bmp');  // bitmap mask
    EMS.ImportFromImage(Bmp);
  finally
    Bmp.Free;
  end;
  SendEMS(EMS, 'My first EMS small picture (16x16) pixels');
end;

procedure TForm1.Button12Click(Sender: TObject);
var
  EMS: TEMSPicture;
  Bmp: TBitmap;
begin
  EMS:= TEMSPictureVariable.Create;  // 72x28 pixels
  EMS.Width:= 72;
  EMS.Height:= 28;
  Bmp:= TBitmap.Create;
  try
    Bmp.Monochrome:= True;
    Bmp.LoadFromFile('logolarge.bmp');  // bitmap mask
    EMS.ImportFromImage(Bmp);
  finally
    Bmp.Free;
  end;
  SendEMS(EMS, 'My first EMS variable picture (72x28) pixels');
end;

procedure TForm1.Button7Click(Sender: TObject);
var
  EMS: TEMSAnimation;
  Bmp: TBitmap;
begin
  EMS:= TEMSAnimationLarge.Create;  // 16x16 pixels
  Bmp:= TBitmap.Create;
  try
    Bmp.Monochrome:= True;
    Bmp.LoadFromFile('anim.bmp');  // bitmap mask
    EMS.ImportFromImage(Bmp);
  finally
    Bmp.Free;
  end;
  SendEMS(EMS, 'My first EMS large animation (16x16) pixels');
end;

procedure TForm1.Button8Click(Sender: TObject);
var
  EMS: TEMSSoundUserDef;
  SndM: TSoundMelody;
  St: TStream;
begin
  EMS:= TEMSSoundUserDef.Create;
  SndM:= TSoundMelody.Create;
  try
    St:= TFileStream.Create('melody.rtt', fmOpenRead);
    try
      SndM.RTTTL:= StreamToString(St);  // load from file in RTTTL format
      EMS.AssignSoundMelody(SndM);
    finally
      St.Free;
    end;
  finally
    SndM.Free;
  end;
  SendEMS(EMS, 'My first EMS sound');
end;

procedure TForm1.SendSEO(aFileName: string);
var
  NBS: TSiemensOTA;
  St: TStream;
  SMS: TSMSSubmit;
  I: Integer;
begin
  SMS:= TSMSSubmit.Create;
  try
    SMS.GSM:= GSM1;
    SMS.DA:= DestAddress;   // destination address
    SMS.DCS:= $F5;          // binary message, class 1
    NBS:= TSiemensOTA.Create;
    try
      NBS.Reference:= fReference mod 256;   // unique id
      Inc(fReference);
      NBS.ObjectName:= ExtractFileName(aFileName);
      NBS.ObjectType:= Copy(LowerCase(ExtractFileExt(aFileName)), 2, 3);  // bmp or mid
      St:= TFileStream.Create(aFileName, fmOpenRead);
      try
        NBS.Data:= StreamToString(St);   // feed binary data
      finally
        St.Free;
      end;
      for I:= 1 to NBS.FragmentCount do   // send particular messages
      begin
        SMS.UD:= NBS.Fragments[I];
        GSM1.SendSMS(SMS);    // send message
      end;
    finally
      NBS.Free;
    end;
  finally
    SMS.Free;
  end;
end;

procedure TForm1.Button9Click(Sender: TObject);
begin
  SendSEO('logo.bmp');
end;

procedure TForm1.Button10Click(Sender: TObject);
begin
  SendSeo('melody.mid'); // monophonic
end;

procedure TForm1.SendWapPush(aWapPushObj: TWapService; aType: Byte);
var
  NBS: TUDHProtocol;
  SMS: TSMSSubmit;
  I: Integer;
  WD: TWapDocument;
begin
  SMS:= TSMSSubmit.Create;
  try
    SMS.GSM:= GSM1;
    SMS.DA:= DestAddress;   // destination address
    SMS.DCS:= $F5;          // binary message, class 1, ME
    SMS.UDHI:= True;
    NBS:= TUDHProtocol.Create;
    try
      NBS.Options:= [{smspoReference, }smspoAddressing];
      NBS.DestinationAddress:= smPortWAPPushConnectionlessSessionService_client;
      NBS.SourceAddress:= smPortWAPConnectionlessSessionService;
      WD:= TWapDocument.Create;
      try
        aWapPushObj.AssignToWapDocument(WD);   // encode as WAP document
        NBS.Data:= #01#06#01+Chr(aType or $80)+WD.WBXMLData;  // magic header
      finally
        WD.Free;
      end;

      NBS.Reference:= fReference mod 256;
      Inc(fReference);

      for I:= 1 to NBS.FragmentCount do   // send particular messages
      begin
        SMS.UD:= NBS.Fragments[I];
        GSM1.SendSMS(SMS);                // send message
      end;
    finally
      NBS.Free;
    end;
  finally
    SMS.Free;
  end;
end;

procedure TForm1.Button11Click(Sender: TObject);
var
  WP: TWapServiceIndication;
begin
  WP:= TWapServiceIndication.Create;
  try
    WP.HRef:= 'http://www.2p.cz/wap/example/test.jpg';  // object address
    WP.Caption:= 'My first launching bird';  // description that appear in SMS
    SendWapPush(WP, $2E);
  finally
    WP.Free;
  end;
end;

end.

⌨️ 快捷键说明

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