views:

125

answers:

2

I have a program on a Windows XP computer on another continent. If I start it by double-clicking on an associated file, so that it runs the program according to the file-type association, it crashes at a certain point. If I start it by dragging an associated file to the program icon, it works fine. If I double-click on the icon and drag the associated file to the window, it works fine.

The guy on site assures me that he's triple-checked the file-type association, and it should be correct.

Assuming that the icon points to the same executable as the registry, what differences would there be in starting the program in these two different ways?

EDIT: In response to a comment, the machine I'm having problems on is running in Japanese, while my normal machine is US English.

+1  A: 

When you double click the file, the program is run, and (usually) the name of the file that you double click, is passed in to the program as a command line argument.

When you are dragging onto the window, the program is already running.

The difference is obviously in the startup process that the program has. Is this software written in-house? Perhaps check how it handles starting up, and make sure that all appropriate code paths are still executed when there is a file in the command line arguments.

If you can't check the program code, or how it behaves at startup, about the only thing to check in the registry, and possibly change, is how the filename is passed in. Usually they are passed in inside talking marks, so that the path to the file can have spaces and not confuse the program. Something to try would be to make sure the association uses talking marks on the argument, or if it already does, try it without. Perhaps the program isn't handling the talking marks correctly.

Ch00k
+3  A: 

One possible difference is the initial working directory: if you drag a file onto the executable, the initial working directory is set to the directory containing the executable, whereas if you double click the file, the initial working directory is set to some default value independent of where the file or executable is located.

If you want to get consistent behavior in all cases, you can use SetCurrentDirectory() to set the current working directory to whatever you want; I recommend the directory containing the executable, which can be found by calling GetModuleFileName(NULL, ...) and stripping off the executable name, or by examining argv[0] inside main().

Adam Rosenfield