Re: Pass in additional command line arguments to a single instance app
- From: p19010101@xxxxxxxxx
- Date: 24 Jan 2007 04:18:41 -0800
Thanks Igor,
I have later discovered that many MS apps are using DDE to pass in
command line arguments, so it must be the way to go. Unfortunately
implementing a DDE server looks awfully complicated, and if I go down
that path I will probably spend more time mucking around DDE instead of
coding the app's core logic.
Anyway, so far I've managed to get SendMessage/WM_COPYDATA working, and
it's pretty much what I wanted except that there's a minor
problem......
I added a key in the Registry: HKCR\*\shell\Open with My
App\command\myapp.exe %1, so that user can right click a file in
Explorer to send the filename to my app. The selected filename is then
passed through %1 to __argv[1]. This mechanism works fine if only 1
file was selected. However, if multiple files were selected, say 5,
Explore actually calls my app 5 times passing in 1 file at a time and
some files were skipped.
I think the problem is that the 1st instance was still creating and not
yet ready to receive the message. So I added a Sleep just before
SendMessage, this patches the problem but introduces unnecessary delays
for all subsequent calls to my app.
Am I doing something wrong? Is there a way to ensure a message was sent
and received succesfully (other than sending back an ACK)?
Cheers!
On Jan 24, 3:23 pm, "Igor Tandetnik" <itandet...@xxxxxxxx> wrote:
<p19010...@xxxxxxxxx> wrote in messagenews:1169611725.040978.239220@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Qestion is how to pass the new filenames (as command line arguments)precisely this purpose.
to the loaded app? I'm looking at DDE at the moment but it seems not
the best way to do this, are better alternatives exist?DDE is the only mechanism natively supported by Windows shell for
You don't have to use it of course. Without it, the second instance of
the application will run; it can detect the first instance, communicate
its command line to said instance using any IPC mechanism, then
immediately terminate.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: Pass in additional command line arguments to a single instance app
- From: Norman Bullen
- Re: Pass in additional command line arguments to a single instance app
- From: Ben Voigt
- Re: Pass in additional command line arguments to a single instance app
- References:
- Pass in additional command line arguments to a single instance app
- From: p19010101
- Re: Pass in additional command line arguments to a single instance app
- From: Igor Tandetnik
- Pass in additional command line arguments to a single instance app
- Prev by Date: NT Service Executable Change - System has memory of previous one?
- Next by Date: Re: visual c++ 2005 sp1 redistributable
- Previous by thread: Re: Pass in additional command line arguments to a single instance app
- Next by thread: Re: Pass in additional command line arguments to a single instance app
- Index(es):
Relevant Pages
|