Re: passing multiple parameters to an application via windows explorer

From: Craig Reynolds (craig_at_wyldphyre.com)
Date: 12/31/04


Date: 31 Dec 2004 17:29:46 +0800

Jamie wrote:

> Craig Reynolds wrote:
> > Jamie wrote:
> >
> >
> >
> > Thanks for the reply Jamie, but my problem isn't working out how to
> > read the parameters from the command line, it's working out how to
> > have a single instance of my aplication launched, and have all of
> > the files it has been launched for passed into it.
> >
> > i.e. I select 4 files in windows explorer, right click on of them,
> > and select the menu item I have added. The way is currently works
> > is that the application is run for each file, and I want it to run
> > once, and have all of the selected files passed into that single
> > instance.
>
> ok, i must of missed it when i read that,
>
> the simplest way to do this is to make a stub program
> this program will be what the explorer calls, it will
> be simple with no VCL required.. just open the main
> source and create a simple windowless app that simply
> looks at the CMDLINE for its params.
> then it will use the Findwindow to search for the main
> program. if the search fails then it should start the
> main program via the createProcess, then a findWindow can be done
> again to get the window handle of the main program.
>
> when the window handle is obtained, you then can use
> the WM_COPYDATA message, this you sendMessage not postMessage
> to the window of your main app, this message will contain
> the string of your CMNLINE after you have prepared it.
> the main App should process this message and move all the string
> contents to some of its local storage because the pointer here
> will not be valid soon.
> after the sendmessage returns, the little stub program should
> terminate it self.
> P.S.
> you should give your form of the Main App a unique name so that
> findwindow does not stop of some other app that uses the same form
> name. also a unique Title Text could be used.

an interesting, and certainly plausible, idea.

I think for the moment i am going to look into making a COM server
thingy (technical term) to hook into the context menu that way, and see
if I can achieve my goal that way. If I can't them I may very well give
your idea a go.

Thanks for that.



Relevant Pages

  • Re: Only One Instance.
    ... the secondary app the handle info of the original app along with what ... use the FINDWIndow in the Main Source before The ... The name of the mutex has no effect on anything else in your program, ... Creating a window, on the ...
    (comp.lang.pascal.delphi.misc)
  • Re: FindWindow is hanging....
    ... because any string you have depends on the fact that you are looking for a specific window ... in a specific version of the app, ... Since I don't trust FindWindow as far as I can throw a mainframe, ...
    (microsoft.public.vc.mfc)
  • Re: passing multiple parameters to an application via windows explorer
    ... > Thanks for the reply Jamie, but my problem isn't working out how to ... then a findWindow can be done again to ... get the window handle of the main program. ... to the window of your main app, ...
    (alt.comp.lang.borland-delphi)
  • Re: how to bring dialog to front
    ... smart phone 6.0 ... When checking whether your app is already running, ... FindWindow is not quite sufficient. ... This call will wait until the window responds. ...
    (microsoft.public.pocketpc.developer)
  • Re: Only One Instance.
    ... use the FINDWIndow in the Main Source before The ... you could simply create a mutex. ... created the window that the other process is looking for. ... > your app responed to .. ...
    (comp.lang.pascal.delphi.misc)