Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String Parameter
Message
From
12/04/2000 10:24:01
 
 
To
All
General information
Forum:
Visual Basic
Category:
ActiveX controls
Title:
String Parameter
Miscellaneous
Thread ID:
00358658
Message ID:
00358658
Views:
40
I have created a C++ COM DLL containing a function which accepts a "string" type parameter by reference and a "long" parameter by reference. The return value of the function is a long. Internally, the COM DLL calls the API GetUserName() function to load data into the passed parameter references.

I tested the DLL function in VFP and it works fine:

ox = CREATEOBJECT( "SysData.IssSysData" )
cSize = 256 && Integer type
cUser = SPACE( cSize ) && Character type
nResult=ox.IssUserName(@cUser,@cSize)
?"Return = " + ALLTRIM( STR( nResult ) )
?"Size = " + ALLTRIM( STR( cSize ) )
MyId = '>' + LEFT( UPPER( cUser ), cSize - 1 ) + '<'
?MyId
ox = NULL

However, when I try to test the DLL function in VB I get a return value (0) indicating the function failed, gibberish in the character type variable, but the Integer type variable contains the right value. This indicates to me that there is some problem in passing the character type variable reference. I have tried several different declarations and initializations for the character type variable but none have been successful or simply will not compile. An example of the code that compiles and runs but returns bad data is:

Dim retval&
Dim size&
Dim MyUserId$
MyUserId$ = Space(256) ' or =String$(256,0)
Dim objSysData As New IssSysData
' or:
' Dim objSysData
' Set objSysData = CreateObject("SysData.IssSysData")
retval = objSysData.IssUserName(MyUserId$, size)
Label1.Caption = "User ID: " & Left(MyUserId$, size - 1)

What am I missing in how to correctly pass the character type variable in VB to the COM DLL function?

Thanks,
Bill
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Next
Reply
Map
View

Click here to load this message in the networking platform