A
abc2003
Unregistered / Unconfirmed
GUEST, unregistred user!
我用C编写的一个字符串转换DLL
函数声明为
void ConvertString(char * StrIn,char * StrOut)
StrOut的长度不会超过StrIn的长度
我在Delphi是如下调用的:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Edit4: TEdit;
Edit5: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure stringcrypt(datain,dataoutChar);far external 'String.dll';
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var StrIn,StrOut: string;
begin
StrOut := ' ';
StrIn := edit1.Text;
stringcrypt(PChar(StrIn),PChar(StrOut));
edit2.Text := str;
end;
end.
但总是报 Access violation的错。
是不是我的参数声明有错。或者是要为StrOut分配内存。
函数声明为
void ConvertString(char * StrIn,char * StrOut)
StrOut的长度不会超过StrIn的长度
我在Delphi是如下调用的:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
Edit4: TEdit;
Edit5: TEdit;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure stringcrypt(datain,dataoutChar);far external 'String.dll';
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var StrIn,StrOut: string;
begin
StrOut := ' ';
StrIn := edit1.Text;
stringcrypt(PChar(StrIn),PChar(StrOut));
edit2.Text := str;
end;
end.
但总是报 Access violation的错。
是不是我的参数声明有错。或者是要为StrOut分配内存。