Solved

OLE Control

Posted on 1998-05-17
3
240 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

Suggested Solutions

Title # Comments Views Activity
Arduino EDI - Programming language 3 124
Google Analytics 5 179
What .NET URL re-routing tool did I use? 2 91
what type of pointer is this pointer? 3 31
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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

739 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