void* in a parameter in COM function
-
Hello!! how can i use void pointers in a parameter in a funcion of COM class?? I try this: ..........MyFuncion([out,retval] void * pResult) and when i compile it CRASHHHHHHHH!!!!!!!!! please help me... my email is jsanchez@cie.com.mx
-
Hello!! how can i use void pointers in a parameter in a funcion of COM class?? I try this: ..........MyFuncion([out,retval] void * pResult) and when i compile it CRASHHHHHHHH!!!!!!!!! please help me... my email is jsanchez@cie.com.mx
Hi, The problem with any kind of pointers is that you can't return or pass it without marshaling the data it points to. If you are using the pointer to the well-known types, such as Long, BSTR, ... the default marshaling can be used. If you use an array of objects or void pointer you must provide additional information for marshalling. Have a look at the length_is() and other array related attributes of the IDL file. You also can return an array of data using a variant with SAFEARRAY. This is the best thing you can do if you are going to use the component in VB. Regards, Alex Gorev, Dundas Software.
-
Hello!! how can i use void pointers in a parameter in a funcion of COM class?? I try this: ..........MyFuncion([out,retval] void * pResult) and when i compile it CRASHHHHHHHH!!!!!!!!! please help me... my email is jsanchez@cie.com.mx
Hi Jafet, There are several techniques you can use and returning the VOID pointer is not one of them. There is a VERY nice article by Don Box in MSDN explaining your options and advantages/disadvantages. The name of the article is "OLE Q&A". There are several articles with this name and I add the beginning of the article, so it will be easier to find. Regards, Alex Gorev, Dundas Software. ------------------------------------------------------ " OLE Q&A Don Box Don Box has been working in networking and distributed object systems since 1989. He is currently chronicling the COM lifestyle in book form for Addison Wesley, and gives seminars on OLE and COM across the globe. Don can be reached at dbox@braintrust.com. QI am using dual interfaces to expose my objects to both C++ and Visual BasicТ clients. Designing the interfaces was relatively painless once I passed simple data types as method parameters. I now need to pass user-defined structures as parameters and can't get it to work. Any suggestions? .... " -- MSDN. ------------------------------------------------------ ----- Original Message ----- From: Jafet Sanchez Rodriguez To: Sent: Tuesday, July 04, 2000 11:42 AM Subject: Re: [CodeProject] Re: void* in a parameter in COM function > Hi Alex!! > I want to pass a struct from vc to vb .. > > struct A > { > int a; > int b; > float c; > } > > MYSTRUCT A; >