我用DELPHI编的一个dll,想在VB中调用,以下是部份代码
DELPHI
library crypt;{$R *.res}
function max(x:real;y :real):real;
begin
{...
代码部分
...}
end;procedure descrypt(s:string):string;
var
i ,len,half: integer;
R : string;
begin
R :='';
{...
代码部分
...}
descrypt:= R;
end;
exports
max,
descrypt;
begin
end.VB中调用代码如下
Declare Function max Lib "D:\WENBEAN\crypt\crypt.dll" (ByVal x As Double, ByVal y As Double) As Double
Declare function descrypt Lib "D:\WENBEAN\crypt\crypt.dll" (ByVal str As String) as StringPrivate Sub Command1_Click()
Dim str1, str2 As String
str1 = txt1.Text
str2= descrypt(ByVal CStr(str1))
End Sub '调用出错 “内存不该为writen”Private Sub Command2_Click()
Dim x, y As Integer
x = CInt(Text1.Text)
y = CInt(Text2.Text)
Text3.Text = CStr(max(x, y))
End Sub '调用成功请问我该如何才能成功调用函数descrypt?如何修改上面的代码?
请将答案发给[email protected]
DELPHI
library crypt;{$R *.res}
function max(x:real;y :real):real;
begin
{...
代码部分
...}
end;procedure descrypt(s:string):string;
var
i ,len,half: integer;
R : string;
begin
R :='';
{...
代码部分
...}
descrypt:= R;
end;
exports
max,
descrypt;
begin
end.VB中调用代码如下
Declare Function max Lib "D:\WENBEAN\crypt\crypt.dll" (ByVal x As Double, ByVal y As Double) As Double
Declare function descrypt Lib "D:\WENBEAN\crypt\crypt.dll" (ByVal str As String) as StringPrivate Sub Command1_Click()
Dim str1, str2 As String
str1 = txt1.Text
str2= descrypt(ByVal CStr(str1))
End Sub '调用出错 “内存不该为writen”Private Sub Command2_Click()
Dim x, y As Integer
x = CInt(Text1.Text)
y = CInt(Text2.Text)
Text3.Text = CStr(max(x, y))
End Sub '调用成功请问我该如何才能成功调用函数descrypt?如何修改上面的代码?
请将答案发给[email protected]
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货