Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to use GetGuiThreadInfo? Pin
Asyura9-Aug-03 16:54
Asyura9-Aug-03 16:54 
AnswerRe: How to use GetGuiThreadInfo? Pin
Michael Dunn9-Aug-03 17:28
sitebuilderMichael Dunn9-Aug-03 17:28 
Generalsuggest a book for... Pin
Beer269-Aug-03 12:26
Beer269-Aug-03 12:26 
GeneralRe: suggest a book for... Pin
Neville Franks9-Aug-03 12:46
Neville Franks9-Aug-03 12:46 
GeneralTree Control and Menu questions Pin
Binayak9-Aug-03 11:15
Binayak9-Aug-03 11:15 
GeneralRe: Tree Control and Menu questions Pin
Neville Franks9-Aug-03 11:24
Neville Franks9-Aug-03 11:24 
GeneralSilly Excel Pin
Anonymous9-Aug-03 10:50
Anonymous9-Aug-03 10:50 
GeneralRe: Silly Excel Pin
Joey Bloggs10-Aug-03 2:49
Joey Bloggs10-Aug-03 2:49 
If you are correctly releasing your interfaces then the application object UserControl flag is probably the cause.

See Q238987

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q238/9/87.asp&NoWebContent=1


Q192348 may be of interest as well

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/KB/Articles/Q192/3/48.asp&NoWebContent=1

SYMPTOMS
The Office application you are automating continues to reside in memory after your Visual C++ program finishes executing.
CAUSE
Most likely the application is still in memory because you have forgotten to release an acquired interface.
RESOLUTION
Here are some general suggestions and things to looks for when trying to determine the cause of the problem:


If you're using #import, it is very likely you could be running into one of the reference-counting bugs associated with it. Often times the bugs can be worked around, but usually it is preferred to use one of the other Automation methods. #import doesn't work very well with the Office applications because its type libraries and use are fairly complex. Also, such reference counting problems are hard to track down because a lot of the interface-level COM calls are behind-the-scenes when using #import.

Check to see if you are calling any methods that return an IDispatch * (LPDISPATCH), such as Open or New, and ignoring the return value. If you are, then you are abandoning this returned interface and will need to change your code so that you release it when no longer needed.
Gradually comment out sections of your code until the problem disappears, then add it back judiciously to track down where the problem starts.

Note that some applications will stay running if the user has "touched" the application. If this occurs while you are automating, then the application will probably stay running afterwards. The Office applications have a "UserControl" property on the Application object that you can read/write to change this behavior.
Also, some applications will decide to stay running if enough user-interface "action" has occurred. If you intend for the application to exit, then call its Quit() method on the Application object. Word will shutdown regardless of its reference count when Quit is called. This isn't expected COM behavior. Excel, however, will properly just hide itself but stay running until all outstanding interfaces are released. In general, you should release all outstanding references, and only call Quit() if you intend the application to quit.

GeneralRe: Silly Excel Pin
Anonymous10-Aug-03 10:32
Anonymous10-Aug-03 10:32 
GeneralRe: Silly Excel Pin
Joey Bloggs10-Aug-03 17:13
Joey Bloggs10-Aug-03 17:13 
GeneralRe: Silly Excel Pin
Anonymous11-Aug-03 9:52
Anonymous11-Aug-03 9:52 
GeneralForcing "cout" to show what's in its buffer. Pin
WREY9-Aug-03 9:49
WREY9-Aug-03 9:49 
GeneralRe: Forcing "cout" to show what's in its buffer. Pin
Nick Parker9-Aug-03 9:57
protectorNick Parker9-Aug-03 9:57 
GeneralRe: Forcing "cout" to show what's in its buffer. Pin
WREY9-Aug-03 10:28
WREY9-Aug-03 10:28 
GeneralProblem found. Pin
WREY9-Aug-03 11:21
WREY9-Aug-03 11:21 
GeneralRe: Forcing "cout" to show what's in its buffer. Pin
Hosam Aly Mahmoud9-Aug-03 11:46
Hosam Aly Mahmoud9-Aug-03 11:46 
GeneralRe: Forcing "cout" to show what's in its buffer. Pin
Jonathan de Halleux11-Aug-03 1:25
Jonathan de Halleux11-Aug-03 1:25 
Questionadding gutters to rich edit controls? Pin
mcguile2579-Aug-03 8:20
mcguile2579-Aug-03 8:20 
GeneralCalling an SDI from another SDI Pin
skea9-Aug-03 8:06
skea9-Aug-03 8:06 
QuestionMinimize to sys tray when someone tries to close the dialog? Pin
Varun Shoor9-Aug-03 7:28
Varun Shoor9-Aug-03 7:28 
AnswerRe: Minimize to sys tray when someone tries to close the dialog? Pin
User 66589-Aug-03 7:36
User 66589-Aug-03 7:36 
AnswerRe: Minimize to sys tray when someone tries to close the dialog? Pin
wb9-Aug-03 7:36
wb9-Aug-03 7:36 
GeneralRe: Minimize to sys tray when someone tries to close the dialog? Pin
User 66589-Aug-03 7:44
User 66589-Aug-03 7:44 
GeneralRe: Minimize to sys tray when someone tries to close the dialog? Pin
Varun Shoor9-Aug-03 7:49
Varun Shoor9-Aug-03 7:49 
GeneralRe: Minimize to sys tray when someone tries to close the dialog? Pin
User 66589-Aug-03 8:25
User 66589-Aug-03 8:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.