?? unit1.~pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
edtdev: TEdit;
Label1: TLabel;
edtsrv: TEdit;
Label2: TLabel;
edtnum: TEdit;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
function GetModuleInformation:LPCTSTR;stdcall;external 'SimplePCConnect.dll';
function InitializePCConnect(nInitializeStatus:dword):BOOL;stdcall;external 'SimplePCConnect.dll';
procedure UninitializePCConnect;stdcall;external 'SimplePCConnect.dll';
function OpenPCConnect(nDeviceNumber:dword;lpszLicence:LPCTSTR;lpszSCA:LPCTSTR):BOOL;stdcall;external 'SimplePCConnect.dll';
function ReopenPCConnect(nDeviceNumber:dword):BOOL;stdcall;external 'SimplePCConnect.dll';
procedure ClosePCConnect(nDeviceNumber:dword);stdcall;external 'SimplePCConnect.dll';
function GetAuthorization(nDeviceNumber:dword):BOOL;stdcall;external 'SimplePCConnect.dll';
function DetectPCConnect(nDeviceNumber:dword):BOOL;stdcall;external 'SimplePCConnect.dll';
procedure SetStatusReceiptRequested(bStatusReceiptRequested:BOOL);stdcall;external 'SimplePCConnect.dll';
procedure SetRejectDuplicated(bRejectDuplicated:BOOL);stdcall;external 'SimplePCConnect.dll';
procedure SetProtocolIdentification(bProtocolIdentification:Byte);stdcall;external 'SimplePCConnect.dll';
function SetUTF8Content(lpszContent:LPCTSTR;bImmediateDisplay:BOOL):BOOL;stdcall;external 'SimplePCConnect.dll';
function Set7BitContent(lpszContent:LPCTSTR):BOOL;stdcall;external 'SimplePCConnect.dll';
function SetBinaryContent(lpszContent:LPCTSTR;bHeaderIndication:BOOL):BOOL;stdcall;external 'SimplePCConnect.dll';
procedure ClearContent;stdcall;external 'SimplePCConnect.dll';
function SendContent(nDeviceNumber:dword;lpszTerminalAddress:LPCTSTR):BOOL;stdcall;external 'SimplePCConnect.dll';
function ReceiveContent(nDeviceNumber:dword;lpszTerminalAddress:LPSTR;
lpszContent:LPSTR):BOOL;stdcall;external 'SimplePCConnect.dll';
function GetStatus(nDeviceNumber:dword):integer;stdcall;external 'SimplePCConnect.dll';
var
Form1: TForm1;
open:Boolean;
info:pchar;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
devnum:dword;
begin
devnum:=strtoint(edtdev.Text);
if not open then
begin
if not DetectPCConnect(devnum) then showmessage('不支持AT命令');
if (devnum>255) or (devnum<0) then showmessage('設備號超出范圍');
if not OpenPCConnect(devnum,pchar('243BABCF4269AAD2E2461F3C84B946F6'),pchar(edtsrv.Text)) then
showmessage('打開設備失敗')
else open:=true;
If not GetAuthorization(devnum) Then showmessage('未授權');
SetStatusReceiptRequested(true);
SetProtocolIdentification(0);
if not SetUTF8Content(pchar(memo1.Text),false) then
showmessage('設置中文短信失敗');
end;
if not SendContent(devnum,pchar(edtnum.Text)) then
case GetStatus(devnum) of
1:showmessage('串口設備失效');
2:showmessage('AT指令執行成功');
3:showmessage('AT指令執行錯誤');
4:showmessage('GSM網絡執行指令錯誤');
5:showmessage('硬件設備錯誤');
end
else showmessage('發送成功');
if open then
begin
ClosePCConnect(devnum);
open:=false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
InitializePCConnect(0);
open:=false;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if open then
begin
ClosePCConnect(strtoint(edtdev.Text));
freemem(info);
end;
UninitializePCConnect;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -