各位大侠:
我将定义部分贴出,此两DLL在delphi中运行没问题.
vb中定义如下:
Private Declare Function RW_CLOSE Lib
"new_Dll.dll" (ID As Integer) As Integer
Private Declare Function RW_REQUEST Lib
"new_Dll.dll" (ID As Integer, ByVal lpstr_s As String) As Integer
Private Declare Function RW_RESET Lib
"new_Dll.dll" (ID As Integer) As Integer
Private Declare Function R_MIM Lib "new_Dll.dll"
(ID As Integer, adds As Integer, numb As Integer, ByVal lpstr_s As String) As Integer
Private Declare Function W_MIM Lib "new_Dll.dll"
(ID As Integer, adds As Integer, numb As Integer,
lpstr_s As String) As Integer
Private Declare Function ReverseStr Lib
"reverse.dll" (ByVal m_str As String) As Integer
Private Declare Function Squared Lib
"reverse.dll" (var_n As Integer) As Integer
DLL中定义如下:
function RW_OPEN(ID:Integer):Integer;export;stdcall;
function RW_CLOSE(ID:Integer):Integer;export;stdcall;
function W_MIM(ID:integer;address:Integer;number:Integer;
m_string:string):integer;export;stdcall;
function R_MIM(ID:integer;address:Integer;number:Integer;
var text
Char):integer;export;stdcall;
function RW_REQUEST(ID:integer;var Chipn
Char)
:integer;export;stdcall;
function RW_RESET(ID:Integer):integer;export;stdcall;
function Squared(var va:integer):integer;export;stdcall;
function ReverseStr(StrToReverse
char):integer;export;stdcall;
ReverseStr和Squared两函数运行正确.
另:如下两处定义的表达方式使我感到迷惑.
1.DLL中ReverseStr的参数未定义为var,在vb中定义时加byval,
参数能带回反转结果;
2.DLL中Squared的参数定义加var,在vb中不用加byval,参数能带回平方值.
不知为何?