C
cooldren
Unregistered / Unconfirmed
GUEST, unregistred user!
一个发短信的接口
有VB的调节器用过程,成功注册组件后,在VB的“工程—引用—浏览”中,选择MsgSDK.dll,点确定。使用时,变量声明部分先声明(如Dim Sendsms As MsgSDK.sms),之后在调用函数之前创建一个实例(Set Sendsms As New MsgSDK.sms),然后就可以调用DLL中的各个函数(如rslt=Sendsms.GetInfo(username,password))了,但我在delphi中就调用不成功,不论是静态的还是动态的。
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMainFrm = class(TForm)
Button1: TButton;
edt: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
{ Public declarations }
end;
var
MainFrm: TMainFrm;
implementation
{$R *.dfm}
function GetInfo(Usernamechar;Passwordchar)char;stdcall;external 'MsgSDK.dll' name 'getinfo';
type TGetFee=function(Usernamechar;Passwordchar)char;
procedure TMainFrm.Button2Click(Sender: TObject);
var
// Sendsms:MsgSDK.sms ; //看VB里面,好像要定义一下,再create,过不去
aa:string;
begin
// GetInfo(pchar('aaa'),pchar('aaa')); //出错,无法定位getinfo
end;
procedure TMainFrm.Button1Click(Sender: TObject);
var
hHandle:THandle;
GetInfo:TGetInfo;
begin
hHandle:=LoadLibrary('MsgSDK.dll');
if hHandle>=32 then
begin
showmessage('loadOK');
@GetInfo:=GetProcAddress(hHandle,pchar('GetInfo'));
if @GetInfo<>nil then
begin
showmessage('OK');
edt.text:=GetInfo('daymoney','qqaazz');
end
else
showmessage('nil'); [red]//总是提示nil[/red]
FreeLibrary(hHandle);
end;
end;
有VB的调节器用过程,成功注册组件后,在VB的“工程—引用—浏览”中,选择MsgSDK.dll,点确定。使用时,变量声明部分先声明(如Dim Sendsms As MsgSDK.sms),之后在调用函数之前创建一个实例(Set Sendsms As New MsgSDK.sms),然后就可以调用DLL中的各个函数(如rslt=Sendsms.GetInfo(username,password))了,但我在delphi中就调用不成功,不论是静态的还是动态的。
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMainFrm = class(TForm)
Button1: TButton;
edt: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
{ Public declarations }
end;
var
MainFrm: TMainFrm;
implementation
{$R *.dfm}
function GetInfo(Usernamechar;Passwordchar)char;stdcall;external 'MsgSDK.dll' name 'getinfo';
type TGetFee=function(Usernamechar;Passwordchar)char;
procedure TMainFrm.Button2Click(Sender: TObject);
var
// Sendsms:MsgSDK.sms ; //看VB里面,好像要定义一下,再create,过不去
aa:string;
begin
// GetInfo(pchar('aaa'),pchar('aaa')); //出错,无法定位getinfo
end;
procedure TMainFrm.Button1Click(Sender: TObject);
var
hHandle:THandle;
GetInfo:TGetInfo;
begin
hHandle:=LoadLibrary('MsgSDK.dll');
if hHandle>=32 then
begin
showmessage('loadOK');
@GetInfo:=GetProcAddress(hHandle,pchar('GetInfo'));
if @GetInfo<>nil then
begin
showmessage('OK');
edt.text:=GetInfo('daymoney','qqaazz');
end
else
showmessage('nil'); [red]//总是提示nil[/red]
FreeLibrary(hHandle);
end;
end;