Stacy
 
 
function AddUser(PUserName, PFullName, PGroupName: PChar; PActive: Boolean): PChar; stdcall;
 [...]
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.
 
 
Any suggestions on how to get this to work?
 
I think the problem is in that string return value
 
a "string" is not the same as a pointer to char - at least
not in the Looking Glass world of VB
 
Add the following declaration to your VB calling program:
 
Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (lpString1 As Any, ByVal lpstring2 As String) As Long
 
declare your DLL function like this (note the return value):
 
Declare Function AddUser Lib "cjnhosting.dll" _
    (ByVal PUserName As String, ByVal PFullName As String, _
    ByVal PGroupName As String, ByVal PActive As Integer) As Long
 
and call it like this
 
    dim retAddUser as long
 
    retAddUser = AddUser(...)
    lstrcpy(retAddUser,LString)
 
 
I haven't actually tried this so I hope I have this right.   
 
 
-ns

Reply via email to