Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Closing open Win32 Applications

by kcella (Beadle)
on Dec 05, 2003 at 22:02 UTC ( [id://312668]=perlquestion: print w/replies, xml ) Need Help??

kcella has asked for the wisdom of the Perl Monks concerning the following question:

I am using WIn32::OLE to access the windows library functions of XMLSpy. I want the wrapper class I created to have a method to close any open instances of XMLSpy. I am using Win32::OLE->GetActiveObject to loop through the open copies and call the XMLSPy Quit method on each of them unitl there are no more left. But, when I test the code it does not work (I have one copy/window open). The method completes successfully, but the app remains open. Here is the code:

# close all running instances of XMLSpy while($open_app=Win32::OLE->GetActiveObject,'XMLSpy.Application')) { $open_app->Quit; if( Win32::OLE->LastError() ) { exit 0; } undef $open_app; }

Is it possible to do this? I know the Quit method works, because I can close an XMLSpy app when none are already open and create my own object reference. thanks, Kevin

Replies are listed 'Best First'.
Re: Closing open Win32 Applications
by NetWallah (Canon) on Dec 06, 2003 at 22:55 UTC
    There may be a bug that causes XMLSpy to run in a different user context.

    Check out this Microsoft MSDN article for a similar problem/solution in Access.

      I attempted the context fix from Microsft, but the app still does not close. When I test the application, I create the open instance of XMLSpy by using the standard windows GUI (I click on the shortcut icon). I use pertty much all the other OLE methods with the open window, but I can never get it to quit the application. There must be a difference between an OLE object created in PERL or one created by an interactive user.
Re: Closing open Win32 Applications
by Nitrox (Chaplain) on Dec 06, 2003 at 13:12 UTC
    I have run into situations where an application doesn't properly register itself in the ROT (Running Object Table), so GetActiveObject() doesn't "see" an app instance.

    You can use a utility called IROTVIEW to view the ROT realtime.

    -Nitrox

      That is not the case here...I can retrieve the OLE object for the one copy of XMLSpy I have open, but the Quit method just doesn't seem to be closing it out.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://312668]
Approved by HyperZonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-26 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found