Re: Who started me?
- From: "Anthony England" <aengland@xxxxxxxxxx>
- Date: Tue, 28 Feb 2006 09:42:35 +0000 (UTC)
"Tom van Stiphout" <no.spam.tom7744@xxxxxxx> wrote in message
news:6sm7021rbh6nqv76gp7lvp1c6q301dbbi6@xxxxxxxxxx
I have a "Launcher" application that does version checking. It will
copy a newer version from the server if needed, and then start the
main application. I believe Tony Toews "Auto FE Updater" serves a
similar purpose. My app calls ShellExecute to run the command line
specified in a "Launcher.ini" file. A typical command line may be:
AppCommandLine="C:\Program Files\Microsoft
Office2003\OFFICE11\MSACCESS.EXE" C:\Test\Test.mde
This all works fine. The path to MsAccess is typically there because
my users often have more than one version installed.
Now I want to know if my application was started by Launcher, or by
some other way. I would then refuse to run. My first idea was to add:
/x LaunchedByLauncher
to the command line. This macro would call a function that would set a
global variable, which I could test for in my startup code.
Alas, /x runs too late: the AutoExec macro runs first, then the /x
macro runs.
So I'm open to suggestions. How can I know who started me?
One thought is to keep Launcher.exe running a bit longer (currently it
is start-and-terminate), and then call FindWindow to see if it is
running. Seems like a cumbersome process and technically I would not
be 100% sure that instance of Launcher started Me.
Thanks,
-Tom.
If your app is launched by an exe then nobody can see the command line with
which the exe launched the app. So you could specify a command-line option
using /cmd and pick this up with the Command function.
Because both the exe and the mde application are compiled, then you could
hard-code this secret code in both applications, effectively proving whether
or not launcher.exe was used or not.
Here is an example:
The shortcut might be:
"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" "C:\Demo\Demo.mdb"
/cmd "SecretCode"
Then your AutoExec macro has just one step: RunCode with
function=DoStartup()
You have a module 'modStartup' with the following function in it:
Public Function DoStartup()
Dim strCommand As String
strCommand = Command()
If StrComp(strCommand, "SecretCode", vbBinaryCompare) = 0 Then
MsgBox "Launched by launcher", vbInformation
Else
MsgBox "Not launched by launcher", vbCritical
Application.Quit
End If
End Function
This approach allows you to check this value at any point once the database
is open, so there is no need to use a global variable. For example, a
button's OnClick event could be MsgBox Command()
.
- Follow-Ups:
- Re: Who started me?
- From: Tom van Stiphout
- Re: Who started me?
- References:
- Who started me?
- From: Tom van Stiphout
- Who started me?
- Prev by Date: Re: Conversion of an MS Access application
- Next by Date: Re: Conversion of an MS Access application
- Previous by thread: Re: Who started me?
- Next by thread: Re: Who started me?
- Index(es):