Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Populating an in parameter array
Hi! I have to create a com object that receives an array as an in parameter and populates it. The syntax of the following function is as follows:
HRESULT GetSessions([in] long lClientID, [in] VARIANT vaSessions)
Precondition:
• vaSessions.vt must be either VT_ARRAY | VT_UNKNOWN or VT_ARRAY |
VT_DISPATCH.
• The SAFEARRAY contained in vaSessions must have exactly the same number of elements as
the client has sessions.
Postcondition:
• The SAFEARRAY in vaSessions will contain the ISession objects corresponding to the client’s sessions.
My function receives the array. However, I cannot populate it. It seems that the array's elements are objects but I cannot access them. When I try to set the array's elements to objects returned by the createObject function, they can be populated but the array returned is empty.
The functional spec contains the following note:
The vaSessions parameter is an [in] parameter. This conflicts with COM rules because data are returned in this parameter. However, due to the fact that the Database component is loaded inproc and not marshaled, this method works correctly.
The Note indicates that what I am trying to do is illegal but should work anyway. Is there something I need to do to make it work anyway? I am really stuck. Any help would be greatly appreciated.
Thanks,
Eylon
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement