Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Com dll Q - Passing back arrays

Status
Not open for further replies.

LizardKingSchwing

Programmer
Oct 12, 2001
96
0
0
NL
I have a COM Dll done in VC++ which currently has two public functions, which pass back simple types e.g. BOOL or Integer. I have to be able to pass back an Array of type String , Integer where the string part is a name and the integer is a number value associated with name.

Not too sure if this is possible , has anyone got any pointers , samples , hints on doing this


Any help appreciated

Cheers

LK--<
 
You could try turning your array into a cursor then using the CURSORTOXML function. Then RETURN the XML file, or store as a public variable in your object. You can then use the XMLTOCURSOR function at the other end to extract into a local cursor etc etc....
 
Not too sure what you are talking about here isnt that a Microsoft Visual FoxPro Language Reference, I did my component in VC++ ;

Any other hints , tips , pointers please ?

Cheers

Alan
 
You may consider using a SAFEARRAY type (it is safety for scripting languages callyour method).
Or, if you are not planning use this component for scripting language (including VB), see, for ex., MIDL array in MSDN and all related topics.

Ex. of IDL:
SAFEARRAY of some structure:
HRESULT GetAccounts([in] long sessHandle, [in] BSTR custNumber, [out] SAFEARRAY(ACCMAIN) * Accounts);
Real arrays:
HRESULT TestMe([in] int cSize, [in, out, size_is(cSize)] TEST tests[]);
Good luck:)
 
Got it working using SAFEARRAY - cheers

I've another quick question , I want to try to see if I can also do the following -

Have an array in the com object which will be filled up by a function , then another function will return values from this array to the .asp page e.g

'call the function to set the array
myObject.setArray
status = myObject.getfromArray(&quot;John&quot;)

' here status will be the matched array element that links to name - John

Is this doable or will the array be lost between function calls. Any pointers, help etc. would be great

LK--<
 
Of course u can !!!! As long as you do not release the object pointer , you should not have any problem..!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top