Solved

OLE Control

Posted on 1998-05-17
3
241 Views
Last Modified: 2013-11-25
Hello,
I am tryng to control a Word 8.0 session throughout a C++ program
via OLE mechanism.
I want my C program, after the activation of Word, be waiting for the
closure of Word session, and then take again control.
Now my program doesn't work this way because, after the OLE activation
I have no more information about the process,(I look for something like WaiforSingleProcess ...)
It seems to me that no parameters in the ole call is good for my goal.
Neverless ... this sound to me a usual problem in Ole Automation ...
 
The hearth of my code is:

    // Create an instance of the automation object and ask for the IDispatch interface
    hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER,
                          IID_IUnknown, (void FAR* FAR*)&punk);
    if (FAILED(hr))
        goto error;
                   
    hr = punk->QueryInterface(IID_IDispatch, (void FAR* FAR*)&pdisp);
    if (FAILED(hr))
        goto error;

    *ppdisp = pdisp;
    punk->Release();

I do obtain pointer to the memory exchange area,
but can't have information about the process underlying (the Word process).
So, ... after this call, my process goes on, and I haven't information
about the closure of the process...

I look forward for an answer from an experienced C programmer.

                        Thank you
                       Santo

0
Comment
Question by:camporelle
[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
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 150 total points
ID: 1162688
OLE automation is supposed to be used when the server is doing something useful for you. If the server has a UI and is started as a server, the UI interaction cannot cause the program to really exit. The UI interaction will only cause the UI to go away. The server is still running, although there is no UI. The controller has full control over when the server can run and not run. No UI interaction can break that contract between the controller and server.

If you want to know when the user wants to quit, then I would suggest subclassing the main window of Word and catch the WM_DESTROY message.

Another idea is to not use automation, but use CreateProcess() and use WaitForSingleObject() to know when the process has terminated.
0
 

Expert Comment

by:footloose
ID: 1162689
You might want consider writing a WordBasic macro to notify your application (like posting a message or writing a semaphore file) when it exits.
0
 

Author Comment

by:camporelle
ID: 1162690
I can't use CreateProcess because I have no more a OLE connection.
More interesting the subClassing.
How can I do it ?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

696 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