Solved

Structure as parameter to OLE Automation function

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

808 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