R
rob
Unregistered / Unconfirmed
GUEST, unregistred user!
我用DELPHI写了一个非常简单的DLL做试验,让VB调用,
发现用除了PCHAR类型以外得所有类型做为传递参数在VB就能调用成功,可是一用PCHAR,
VB调用的时候老是关闭性错误!
请那位高人指点迷经(函数调用一定得有字符参数)
程序如下:
Delphi DLL
**********************************
library Project1;
uses
SysUtils,
Classes;
{$R *.res}
function robtest(VAR bufchar):integer;stdcall;
begin
buf:='rob';
result:=2003;
end;
exports
robtest;
begin
end.
*************************************************
VB 调用程序
Private Declare Function robtest Lib "c:/windows/desktop/dll/test/Project1.dll" (ByVal buf As String) As Long
Private Sub Command1_Click()
Dim a As Integer
Dim bb As String
a = robtest(bb)
Text1.Text = Text1.Text + bb + ";" + Str(a)
End Sub
**************************************************
发现用除了PCHAR类型以外得所有类型做为传递参数在VB就能调用成功,可是一用PCHAR,
VB调用的时候老是关闭性错误!
请那位高人指点迷经(函数调用一定得有字符参数)
程序如下:
Delphi DLL
**********************************
library Project1;
uses
SysUtils,
Classes;
{$R *.res}
function robtest(VAR bufchar):integer;stdcall;
begin
buf:='rob';
result:=2003;
end;
exports
robtest;
begin
end.
*************************************************
VB 调用程序
Private Declare Function robtest Lib "c:/windows/desktop/dll/test/Project1.dll" (ByVal buf As String) As Long
Private Sub Command1_Click()
Dim a As Integer
Dim bb As String
a = robtest(bb)
Text1.Text = Text1.Text + bb + ";" + Str(a)
End Sub
**************************************************