Loading Exe from within another exe 
Author Message
 Loading Exe from within another exe

I have two programs i have written, I  load one exe from within the other,
using the shell command, but you can load multiple copies of the exe.  How
do i check to see if the exe has been loaded and exit the procedure so only
one copy of the exe can be loaded at one time?
thanks


Fri, 15 Mar 2002 03:00:00 GMT  
 Loading Exe from within another exe
On Mon, 27 Sep 1999 17:39:02 +0100, "Sally White"
Quote:

> I have two programs i have written, I  load one exe from
within the other,
> using the shell command, but you can load multiple copies of
the exe.  How
> do i check to see if the exe has been loaded and exit the
procedure so only
> one copy of the exe can be loaded at one time?
> thanks

This should do what you want based upon what you asked:

If you are running the second EXE from only one subroutine in
your program, then create a static variable in that subroutine, of
type Variant.  Use that variable to store the process ID returned
by the shell command.

You can then have your subroutine check if the process ID is 0
or non-zero. If it is non-zero, then exit the subroutine:

Public Sub MyLoader()
  Static processID as Variant

  If processID <> 0 Then Exit Sub
  processID = Shell(...)
End Sub

If your command is loaded in several subroutines in a form or
class, or if it is mulitiple classes, then you will have to use a
private or public global variable respectively.

Notes:
You should check that the Shell command did indeed load the
external EXE.  The documentation indicates that the command
will raise an error if it fails.

If some other process besides your program could have loaded
the external EXE (thus a static or global will be of no help), then  
I think that you are going to have to do some API work to
search the running tasks.

Hope that helps.



Fri, 15 Mar 2002 03:00:00 GMT  
 Loading Exe from within another exe
This is what I am using.  There may be a better way but this works.  You
need to
put the title bar string after AppActivate in quotes.  As long as the title
is always the
same this will work.  In this example my app title is "MAJIQ QuikView 2" .

Bob Askey

On Error GoTo NotThere
        AppActivate "MAJIQ QuikView 2"
            MsgBox ("You already have a copy of QV2 open," _
            & Chr(13) & "please close and try again."), _
            vbCritical + vbOKOnly, "App Open Error"
        'end this app
    End

NotThere:
    'checks to see if Majiq Terminal is already open.
   Resume WasNotThere

'after checking that Majiq Terminal is not open continues
'from On Error NotThere resumes to WasNotThere
WasNotThere:
            code continues on from here.


Quote:
> I have two programs i have written, I  load one exe from within the other,
> using the shell command, but you can load multiple copies of the exe.  How
> do i check to see if the exe has been loaded and exit the procedure so
only
> one copy of the exe can be loaded at one time?
> thanks



Fri, 15 Mar 2002 03:00:00 GMT  
 Loading Exe from within another exe
(F1) App.PrevInstance
Neila


Quote:
>I have two programs i have written, I  load one exe from within the other,
>using the shell command, but you can load multiple copies of the exe.  How
>do i check to see if the exe has been loaded and exit the procedure so only
>one copy of the exe can be loaded at one time?
>thanks



Sat, 16 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. starting a VB3 .exe from within a VB3 .exe

2. Get name of initiating exe/dll from within another exe/dll

3. Transport .jpg and .exe within .exe ?

4. Get name of initiating exe/dll from within another exe/dll

5. Problem: Cannot load a DLL from within a VB4 created .EXE

6. Load A new Version of an Exe File From the same Exe file

7. Load A new Version of an Exe File From the same Exe file

8. Specify DLL version when using mc.exe, rc.exe and/or link.exe

9. WANTED: SDK3.1 LIBW.LIB, LIB.EXE, LINK.EXE, RC.EXE

10. DLL entry points within msaccess.exe

11. Embed Database within .Exe or Dll. (VB Winforms)

12. Embedding data files within the EXE (MS QB4.5)

 

 
Powered by phpBB® Forum Software