移动风pdu.dll以动态链接库方式封装了gsm短信息pdu编解码的主要操作,方便用户进行gsm短信息开发。
1. delphi
type
//短信PDU编码
TSMS = record
len: integer;
pdu: string;
end;
PTSMS = ^TSMS;
function PDUEncode(content: PChar): PChar;stdcall;external 'pdu.dll';//中文编码转PDU格式
function PDUDecode(content: PChar): PChar;stdcall;external 'pdu.dll';//PDU解码
function EncodingSMS(center: PChar; phone: PChar; content: PChar;var sms: PTSMS): boolean;stdcall;external 'pdu.dll';//普通SMS编码
2. c#
/// <summary>
/// SMSpdu编码
/// </summary>
public struct TSMS
{
public int len;
public string pdu;
}
[DllImport("pdu.dll ", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
private static extern bool EncodingSMS(string center, string phone, string content, ref IntPtr sms);//普通SMS编码
[DllImport("pdu.dll ", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
private static extern string PDUEncode(string content);//中文编码转PDU格式
[DllImport("pdu.dll ", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
private static extern string PDUDecode(string content);//PDU解码
IntPtr psms = new IntPtr();
EncodingSMS(txtCenter.Text, txtPhone.Text, txtContent.Text, ref psms);
TSMS sms = new TSMS();
sms = (TSMS)Marshal.PtrToStructure(psms, typeof(TSMS));
txtLen.Text = sms.len.ToString();
txtPDU.Text = sms.pdu;
下载:pdu.dll