Re: Pass in additional command line arguments to a single instance app

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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)
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
precisely this purpose.

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

.



Relevant Pages

  • Re: Pass in additional command line arguments to a single instance app
    ... command line arguments, so it must be the way to go. ... implementing a DDE server looks awfully complicated, ... Explorer to send the filename to my app. ... because the first instance just finished its processing and is closing its ...
    (microsoft.public.vc.language)
  • Re: can winteg3 pass data to .net c# app?
    ... a way to pass data back and forth between a wintegrate v3 session and a .net ... to find some mentions of DDE and C# so that might be one possible solution.. ... The problem with both of those is the other app won't see any sort of event ... the ActiveX control and the .NET app --> heck, ...
    (comp.databases.pick)
  • RE: duplicate the FileWebRequest Class
    ... > I have tried building an activex control but it dosnt support the DDE ... > integrating a web site with some of the parts of the phone app. ... > want to be able to pop up my client app when a link is clicked in IE and pass ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: RegisterLaunchApplication Interaction With Shell open/ddeexec
    ... >>Also note that this problem only started occurring when I converted the app ... VC6's DDE support didn't work if your application's name was longer than ... I had to remove my fix to even get the messages flowing. ...
    (microsoft.public.vc.mfc)
  • Re: Parameter
    ... DDE ist in VFP seit Urzeiten eingebaut. ... Auf diese Weise kannst du a) feststellen, ob überhaupt schon deine App ... läuft, und b) der laufenden App deine Befehle übergeben, und die dann wieder ...
    (microsoft.public.de.fox)