关于DLL使用(100分)

  • 主题发起人 主题发起人 zuoc
  • 开始时间 开始时间
Z

zuoc

Unregistered / Unconfirmed
GUEST, unregistred user!
VB中的函数为
Public Declare Function GenClientString Lib "RCClientModulesUpdate.dll&quot
(ByVal pStr As String, ByRef pLen As Long, ByVal DogPassword As Long, ByVal DogCascade As Byte) As Long

Public Declare Function UpdateModule Lib "RCClientModulesUpdate.dll&quot
(ByVal pStr As String, ByVal DogPassword As Long, ByVal DogCascade As Byte, ByVal pLen As Long) As Long
写成DELPHI代码怎么写?
 
代码:
[b]function[/b] GenClientString(pStr: [b]String[/b]
pLen, DogPassword: LongInt
DogCascade: Byte): LongInt
[b]stdcall[/b]
[b]external[/b] 'RCClientModulesUpdate.dll';

[b]function[/b] GenClientString(pStr: PChar
pLen, DogPassword: LongInt
DogCascade: Byte): LongInt
[b]stdcall[/b]
[b]external[/b] 'RCClientModulesUpdate.dll';
 
function GenClientString(pStr:PChar;var pLen:integer;DogPassword:integer;dogCascade:byte):integer;stdcall
external RCClientModulesUpdate.dll';

function UpdateModule (pStr:PChar;DogPassword:integer;DogCascade:byte;pLen:integer):integer;stdcall
external 'RCClientModulesUpdate.dll'
 
VB中的string翻到DELPHI必须翻成PChar,一定不能string的,Delphi中的String数据类型是一种特殊的数据类型,无法传递给VB或者VC写的DLL的
 
用上面两位的方法还是不行,反不回正确的结果。
 
用function GenClientString(var pStr: Pchar
var pLen
const DogPassword: LongInt
var DogCascade: Byte): LongInt
stdcall
external 'RCClientModulesUpdate.dll'
对了,为什么把pStr付给string变量会出错?
 
郁闷:pStr为pChar和pointer时都取不到值。
VB中:
Public DogPassword As Long
Public NetDogResult As Long
Public NetDogData1 As String * 200
Public NetDogBytes As Long
Public DogCascade As Long

NetDogResult = GenClientString(NetDogData1, NetDogBytes, DogPassword, DogCascade)
 
function GenClientString(var pStr: pointer
var pLen
const DogPassword: LongInt
var DogCascade: Byte): LongInt
stdcall
external 'RCClientModulesUpdate.dll'

var
s: Pchar;
s := @NetDogData1;
Edit1.Text := s;
以上方法我取到了NetDogData1。
function UpdateModule(var pStr: pointer
var DogPassword: LongInt
var DogCascade: Byte
var pLen: LongInt): LongInt
stdcall
external 'RCClientModulesUpdate.dll'
这个函数中,我怎么样把string付给pStr?
 
后退
顶部