Author |
Topic |
|
AtiLaw
UK
Posts |
Posted - 05/11/2004 : 10:52:51 AM
|
Hi,
I have recently decided to change a VB6 application which I used DDE to load data into an open origin application through script commands. Now I want to not bother with the user having to open origin and just use the automation server to do what I was doing with the DDE. I can get the automation server working, declare my applicationSI and stuff, but for some reason the instance of origin stays open in the background when i endsession and close the VB app.
I am guessing it is something to do with me having changed the project so it stays open as it needs saving or something, but for the minute I just want to be able to close all existing sessions of origin when closing the session.
Probably a very easy answer to this so sorry if its a silly question!
Laurence
|
|
AtiLaw
UK
Posts |
Posted - 05/11/2004 : 11:07:37 AM
|
Forgot to mention I am using OriginPro 7.5. Thanks. |
|
|
easwar
USA
1964 Posts |
Posted - 05/11/2004 : 12:00:51 PM
|
Hi Laurence,
It could be that the "IsModified" property of Origin is set, which means that your client app made a change to Origin that is "worth" saving the project. So Origin may be waiting for you to decide whether to save the OPJ or not.
So at the end of the client app, you could do the following: OriginApp.IsModified=false OriginApp.Execute("exit;")
The first line resets the "IsModified" flag so that Origin does not wait for user to decide on saving the project or not, when the "exit" command is issued to close the Origin session.
By the way, if the above is the case, and Origin was really waiting for you to decide whether to save or not, even if the Origin session was hidden, this should still have poppued up the "save yes/no" dialog.
As for closing all existing sessions, typically from the client you close only the one you connect to. In order to query and see if there are other sessions, you may need to write some special VB code to call Windows functions to look for apps with name "Origin" and then close them, or something along those lines. But this may not be required if the client cleanly manages the session that it connects to, or launches by itself.
Easwar OriginLab
|
|
|
AtiLaw
UK
Posts |
Posted - 05/14/2004 : 05:11:17 AM
|
Thanks Easwar. I have used the ismodified flag, but have neven seen the exit command before so I will give this a try. I had written VB code before in VB.NET which searched through procid strings for origin then ended the process, but in VB6 its nearly impossible without knowing the process id number (I don't know of a way to use the process id string anyway). Its more a VB problems when tackling it from that angle though. I could possibly just try and connect to use the existing open origin instances, closing each one I connect to until I have closed them all?
Ah well.. will let you know how I get on!
Thanks again. Laurence |
|
|
easwar
USA
1964 Posts |
Posted - 05/14/2004 : 09:56:00 AM
|
quote:
...have neven seen the exit command before so I will give this a try...
I could possibly just try and connect to use the existing open origin instances, closing each one I connect to until I have closed them all?
Hi Laurence,
Note that the Exit command is not part of the COM methods and properties. OriginApp.Execute("exit;") is just sending a LabTalk command string called "exit" to Origin, which ends the Origin session (provided the IsModified is reset so that no prompt is brought up).
Regarding connecting to each existing session and closing them all, the issue is that if you try to connect using ApplicationSI, if a session does not exist, then a new one is launched! So using ApplicationSI you will not be able to connect only to existing sessions and close them.
Alternative would be to write special VB code to use Windows functions to check for existing instances of Origin application. See this post for a sample VB code: http://www.originlab.com/forum/topic.asp?TOPIC_ID=3006
This is a general COM issue. As long as your client application launches a unique instance and cleanly handles the closing of that instance when the client is done, and as long as the user is not independantly launching other instances and killing them etc. at the same time the client is running, things will work out well. Otherwise, the problem is more complicated in my opinion.
Easwar OriginLab
|
|
|
AtiLaw
UK
Posts |
Posted - 05/17/2004 : 05:31:02 AM
|
I started to realised problems with my plan when I actually got time to sit down and think properly about the problem and noticed a few things about COM! Thanks for the link to vba code, its going to be really helpful I think.
I am going to do what I was doing with my DDE version, which is close every instance of origin on execution of the code, and just make sure users dont start any new sessions whilst my software is running.
Thanks again, Laurence |
|
|
|
Topic |
|
|
|