[VC++] Passage de SAFEARRAY en param de fonction dans un composant COM

Passage de SAFEARRAY en param de fonction dans un composant COM [VC++] - Programmation

Marsh Posté le 18-07-2001 à 19:21:45    

Je cherche à passer un tableau (SAFEARRAY) en paramètre d'une fonction d'un composant COM. Mais j'ai une erreur à la compile. Il semble ocnsidérer SAFEARRAY comme dérivant de void ou void*.
voici la déclaration dans le .idl :
 
[id(4), helpstring("method toto" )] HRESULT toto([out] SAFEARRAY xxx);
 
Et l'erreur de compile :  
 
\SearchBDD.idl(24) : error MIDL2139 : type of the parameter cannot derive from void or void * : [ Type 'PVOID' ( Parameter 'xxx' ) ]
\SearchBDD.idl(24) : error MIDL2105 : pointee / array does not derive any size : [ Field 'rgsabound' of Struct 'tagSAFEARRAY' ( Parameter 'xxx' ) ]
\SearchBDD.idl(24) : error MIDL2042 : [out] parameter is not a pointer : [ Parameter 'xxx' of Procedure 'toto' ( Interface 'IReqBdd' ) ]
\SearchBDD.idl(24) : warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'xxx' of Procedure 'toto' ( Interface 'IReqBdd' ) ]
 
Qqu'un aurait une idée ?
Thx

Reply

Marsh Posté le 18-07-2001 à 19:21:45   

Reply

Marsh Posté le 19-07-2001 à 10:18:18    

:hot:

Reply

Marsh Posté le 19-07-2001 à 10:29:13    

Tu est obligé de passer le SAFEARRAY en pointeur.


---------------
[:seblamb] Moi aussi je veux grater dédé!!!
Reply

Marsh Posté le 19-07-2001 à 10:31:55    

J'ai déjà essayé et j'ai la même erreur :
 
Source idl :
[id(4), helpstring("method toto" )] HRESULT toto([out] SAFEARRAY *xxx);
 
Résultat à la compile :
 
SearchBDD.idl(24) : error MIDL2139 : type of the parameter cannot derive from void or void * : [ Type 'PVOID' ( Parameter 'xxx' ) ]
SearchBDD.idl(24) : error MIDL2105 : pointee / array does not derive any size : [ Field 'rgsabound' of Struct 'tagSAFEARRAY' ( Parameter 'xxx' ) ]
SearchBDD.idl(24) : error MIDL2040 : [out] only parameter cannot be a pointer to an open structure : [ Parameter 'xxx' of Procedure 'toto' ( Interface 'IReqBdd' ) ]
SearchBDD.idl(24) : warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'xxx' of Procedure 'toto' ( Interface 'IReqBdd' ) ]

Reply

Marsh Posté le 19-07-2001 à 10:46:40    

Je me rappelle, tu es obligé de passer un pointeur sur un VARIANT qui contient un SAFEARRAY.
Pour les objet COM, le type de param autorisé est très limité.
 
Voici un example que j'ai tiré d'un de mes programmes:
 
HRESULT _stdcall GetWBMessage([out] VARIANT *message_i, [in] VARIANT_BOOL refresh_i);
 
Sa retourne un variant qui contient un liste de chaine de caractère
 un morceau du programme listing C++ qui fait cela
 
    LPSAFEARRAY array  = SafeArrayCreateVector(VT_UI1, 0, strlen(m_message));
    memcpy(array->pvData,m_message,strlen(m_message));
 
    message_i->vt = VT_ARRAY|VT_UI1 ;
    message_i->parray = array;


---------------
[:seblamb] Moi aussi je veux grater dédé!!!
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed