Solved

Structure as parameter to OLE Automation function

Posted on 1998-04-29
4
258 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

920 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

11 Experts available now in Live!

Get 1:1 Help Now