G
goujie
Unregistered / Unconfirmed
GUEST, unregistred user!
在我的dll中有个函数她有三个参数,其中两个是传入参数(Const Com:Integer;Const WriteStringChar;),
一个是输出参数(Var ReturnStringChar),但是我在调用的时候输出参数的值不正确:函数如下:
unit UitMain;
interface
uses
Windows,SysUtils,StdCtrls;
Function SendSMSMessage(Const Com:Integer;Const WriteStringChar;
Var ReturnStringChar):Boolean;far;StdCall;
implementation
Function SendSMSMessage(Const Com:Integer;Const WriteStringChar;
Var ReturnStringChar):Boolean;
begin
ReturnString:=PChar('AAAAAAAA');
Result:=True;
end;
调用如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var aachar;
straa:string;
begin
getmem(aa,1024);
SendSMSMessage(2,PCHAR('ATD 13701192708'+#13),aa);
straa:=string(aa);
freemem(aa);
showmessage(straa);
end;
end.
申明如下:
unit Unit2;
interface
Function SendSMSMessage(Com:Integer;WriteStringChar;ReturnStringchar):Boolean;StdCall;
implementation
Function SendSMSMessage(Com:Integer;WriteStringChar;ReturnStringchar):Boolean;external 'SmsSenderdll.dll' name 'SendSMSMessage';
end.
一个是输出参数(Var ReturnStringChar),但是我在调用的时候输出参数的值不正确:函数如下:
unit UitMain;
interface
uses
Windows,SysUtils,StdCtrls;
Function SendSMSMessage(Const Com:Integer;Const WriteStringChar;
Var ReturnStringChar):Boolean;far;StdCall;
implementation
Function SendSMSMessage(Const Com:Integer;Const WriteStringChar;
Var ReturnStringChar):Boolean;
begin
ReturnString:=PChar('AAAAAAAA');
Result:=True;
end;
调用如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var aachar;
straa:string;
begin
getmem(aa,1024);
SendSMSMessage(2,PCHAR('ATD 13701192708'+#13),aa);
straa:=string(aa);
freemem(aa);
showmessage(straa);
end;
end.
申明如下:
unit Unit2;
interface
Function SendSMSMessage(Com:Integer;WriteStringChar;ReturnStringchar):Boolean;StdCall;
implementation
Function SendSMSMessage(Com:Integer;WriteStringChar;ReturnStringchar):Boolean;external 'SmsSenderdll.dll' name 'SendSMSMessage';
end.