Solved

OLE Control

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

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

Suggested Solutions

Title # Comments Views Activity
wordpress limitations 4 114
How to convert MFC APP to Win32 APP. 19 79
Licensing Sharepoint 2016 for developers 11 45
PL SQL Developer 7 32
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
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…

816 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

12 Experts available now in Live!

Get 1:1 Help Now