Solved

Structure as parameter to OLE Automation function

Posted on 1998-04-29
4
254 Views
Last Modified: 2013-12-04
How do I pass structure as parameter to OLE Automation function? I need to convert C++ function GetPrinterDevMode( DEVMODE* pDevMode) to OLE Automation.
0
Comment
Question by:gelbert
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1397769
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
 
LVL 8

Author Comment

by:gelbert
ID: 1397770
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
 
LVL 8

Author Comment

by:gelbert
ID: 1397771
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
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 150 total points
ID: 1397772
The best thing to do would be to cast those function pointers into generic pointers and cast them back.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now