Stacey, what size is a VB integer? You probably need to make sure that your
"as integer" accesses the same number of bytes as a delphi boolean,
otherwise it may "spill over the edges" (into the function result?). Try
defining PActive as a LongBool instead of a Boolean, and see if the problem
still occurs.
Cheers,
Carl
-----Original Message-----
From: Stacey Verner [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 20 February 2001 1:04 PM
To: Multiple recipients of list delphi
Subject: [DUG]: Using a Delphi DLL in VB/VBA
I have a DLL developed by us in Delphi which our clients are using from VB
and VBA, and we have problems with a function that has a string result.
The Delphi definition is
function AddUser(PUserName, PFullName, PGroupName: PChar; PActive: Boolean):
PChar; stdcall;
which we can access (in the dll) with no problems using
...
TAddUser = function(PUserName, PFullName, PGroupName: PChar; PActive:
Boolean): PChar; stdcall;
...
var
AddUser: TAddUser;
...
@AddUser := GetProcAddress(CJNHostingDLLHandle, 'AddUser');
I havn't tried static loading but there should be no difference.
In VB they use
Declare Function AddUser Lib "cjnhosting.dll" _
(ByVal PUserName As String, ByVal PFullName As String, _
ByVal PGroupName As String, ByVal PActive As Integer) As String
and this crashes (the application just closes with no error messages), but
only when the result is used.
ie. Call AddUser(...) is fine.
LString = AddUser(...) crashes.
We are using PActive As an integer because VB and Delphi boolean types are
different. In VB true is -1.
Any suggestions on how to get this to work?
Thanks
Stacey
Stacey Verner Ph: +64-9-4154790
Software Developer Fax: +64-9-4154791
DDI: +64-9-4154797
CJN Technologies Ltd. Email: [EMAIL PROTECTED]
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"