Solved

Structure as parameter to OLE Automation function

Posted on 1998-04-29
4
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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 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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

691 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