PDA

View Full Version : File Association / DDE



Anonymous
10-14-1999, 01:12 AM
I've written an application that I'd like to take advantage of the Window's shell's file-association capability. I've added entries to the registry to allow me to add verbs to the context menus, and as long as I stick to non-DDE entries, I'm fine.

However, when I try and add DDE hooks to run my application, I come upon an odd problem I just don't know how to get around. If my application is not running, and I launch a file associated with my application via the shell, the shell (and not my application) will throw up the message:

Cannot find the file 'C:\Directory\File.ext' (or one of its components). Make sure the path and filename are correct and that all required libraries are available.

However, even as the error message is displayed, my application continues to properly load and utilize the file.

If I start the application myself and load the file, or if the application is already running when I launch an association, I do not get an error message, and everything works just fine.

Additionally, if I remove the DDEEXEC entry, I no longer encounter this problem. However, its VERY important that my application include the DDE hook, as I expect the user to launch LARGE numbers associated files from Explorer at a time. I've experimented, and the drain on the system is prohibitively high if I allow the shell to launch a copy of my application for each associated file run and have the multiple copies communicate back and forth to consolidate the list of launched files in a single application.

Any idea what I'm doing wrong? I've combed MSDN and searched for quite some time for any info on this sort of thing, but none of the resources I've found seem to talk much on how to do the DDEXEC stuff.

Below is a dump of the registry entries I've added.

I'd appreciate ANY help anyone could give me on this. Thanks.


Irfaan Chaudhry
www.welcome.to/pompous


p.s. If it helps any, the application I'm writing is a media player I've written in VB that's kinda like Nullsoft's WinAmp, which is why I expect so many associations to run at a time.

=================================================

[HKEY_CLASSES_ROOT\SlimAmp.File]
@="Slimamp Media File"
"EditFlags"=hex:00,00,00,00

[HKEY_CLASSES_ROOT\SlimAmp.File\shell]
@="Enqueue&/Play"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Play]

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Play\command]
@="\"C:\\PROGRAM FILES\\LITTLE PROGRAMS\\SLIMAMP.exe\" /play \"%1\""

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Play\ddeexec]
@="/play %1"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Play\ddeexec\ Application]
@="SlimAmp"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Play\ddeexec\ Topic]
@="SACommand"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue]

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue\comma nd]
@="\"C:\\PROGRAM FILES\\LITTLE PROGRAMS\\SLIMAMP.exe\" /enqueue \"%1\""

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue\ddeex ec]
@="/enqueue %1"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue\ddeex ec\Application]
@="SlimAmp"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue\ddeex ec\Topic]
@="SACommand"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue&/Play]
"EditFlags"=hex:01,00,00,00

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue&/Play\command]
@="\"C:\\PROGRAM FILES\\LITTLE PROGRAMS\\SLIMAMP.exe\" /enqueueandplay \"%1\""

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue&/Play\ddeexec]
@="/enqueueandplay(%1)"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue&/Play\ddeexec\Application]
@="SlimAmp"

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Enqueue&/Play\ddeexec\Topic]
@="SACommand"

jstolz
10-14-1999, 02:29 AM
Okay, you're leagues above me here, but I was fascinated by your work, and think I have pinpointed the problem:

You said you get the error message unless the app is already running; that's because you need another subkey:

[HKEY_CLASSES_ROOT\SlimAmp.File\shell\Play\ddeexec\ ifexec]

I get a bit fuzzy here, but I think you need to supply a value corresponding to the [d][path]filename, since the ifexec key tells Windows where to find the DDE application if it isn't already running.

As a matter of interest, I'm not sure why this is required since you've already specified the DDE app path under the command key. I've noted some applications can't seem to handle spaces in folder names, which suggests a bust somewhere where they use the %1 variable.

Anonymous
10-14-1999, 08:39 AM
First off, thanks for the reply jstolz.

I probably should have mentioned that I had played around with ifexec. As it turns out, ifexec only specifies a special DDE string that is used for a special case: If the program is NOT running, the program is then ran, and the DDE string specified by IFEXEC is passed to it.

As for the APPLICATION key, I think it refers to the running application's name, as Windows identifies it, so that Windows can correctly communicate with any running copies via DDE, as opposed to the application's filename. If there's someplace where I'm suppose to hook up that application name to the filename, that *might* be where my problem lays...

Here's the link to the only info I could find on doing this type of registry stuff:
http://support.microsoft.com/support/kb/articles/q122/7/87.asp

Unfortunately, the article appears to leave out the key bit of information I seem to need. :(

The reason I'm trying to use DDE to do this is 2 fold:

1) It is a very common situation that a person will select ALOT of files associated with my program, and run them simultaneously. By using the normal COMMAND mechanism, each associated file runs a unique copy of my program. So if the user selects, say, 40 files, 40 copies of my program will be run. This is a HUGE drain on system resources while the 40 copies attempt to sort out what's going on simultaneously. And in situations where the user selects, say, 100 files, the system is drained to the point that Windows will start throwing up "low resources" messages (for good reason).

2) Only one copy of this program is ever visible to the user. If another copy is run, the new copy needs to see if a copy is already running, and when it finds it, tells the already-running copy what it's been told to do, so the already-running copy can respond appropriately. For an example of this, try using Nullsoft's WinAmp. Now, I can avoid all this searching and communicating if Windows just talks directly to my already-running copy of the program in the first place, which is precisely what DDE does.

As for the %1 for the variables, my program is intelligent enough to handle the spaces, so that ain't the problem, either.

Oh, and as for being "leagues above" you, I hope you don't think I actually know what I'm doing; I just studied Word's registry entires and figured it out from there. I didn't even start looking for other information until this problem became apparent. :)

I really want to release this program to the public, but I just can't get myself to do it with such a glaring bug. Argh...


Irfaan Chaudhry
www.welcome.to/pompous

jstolz
10-14-1999, 08:11 PM
well, I guess that infobase article was a start, but try these links too... there's all kinds of stuff there:

http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/sdkdoc/shellcc/shell/shellext.htm (wait for the left pane to load)
http://technet.microsoft.com/cdonline/default.asp

But more importantly, there is a place where you associate filenames with the app path--look in
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\App Paths

Regards...