Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OLE Control

Posted on 1998-05-17
3
Medium Priority
?
245 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

604 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