Structure as parameter to OLE Automation function

How do I pass structure as parameter to OLE Automation function? I need to convert C++ function GetPrinterDevMode( DEVMODE* pDevMode) to OLE Automation.
LVL 8
gelbertAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Tommy HuiConnect With a Mentor EngineerCommented:
The best thing to do would be to cast those function pointers into generic pointers and cast them back.
0
 
Tommy HuiEngineerCommented:
Unfortunately, you don't. The best way to think about this is that a data structure is an object. So you will need to create an OLE object that mirrors a DEVMODE structure. The new OLE object will have member functions that let you manipulate the various data members of the DEVMODE structure. Then your GetPrinterDevMode() function will take an IDispatch* (or LPDISPATCH).

Another possible way of doing this is to wrap a variant around some memory bytes which happen to be a DEVMODE structure. This is less than ideal because that requires that the server and controller know the DEVMODE structure and how it is laid out in memory. But if you can live with this, then you can just pass a variant around.

0
 
gelbertAuthor Commented:
Thanks for answer thui. But I would like to here any other possible options. If none respond then points are yours. I will post comment here to let you know.
0
 
gelbertAuthor Commented:
Hi thui. Points are yours. Just post something as an answer and I will accept it.
   One more thing my be you have some bright idea except advice to rewrite code (this one I figured out and it is not an option). I convert C++ class into COM object and I have functions which take pointer to function as parameter or return pointer to function. Is ther any COM way of doing it? Problem is that functions do not use these pointers but pass them to another function.
0
All Courses

From novice to tech pro — start learning today.