Malcolm J. Kudra wrote:
> Andre van Zuydam wrote:
>> Well - it could be any file.   In my case its a text file (a php file).  My 
>> programme is open and I want to know when windows wants to open another one 
>> so I can open it in my programme, it being the default
>> editor.  I hope this makes sense.
> 
> Andre, perhaps you could register the .PHP file extension with Windows
> to be associated with (opened by default by your program) at
> initialization time and return the .PHP association to its original
> state as part of your application's finalization routine.
> 
> Would this achieve the effect you need?

That's not what he needs. He needs to know how to make his program 
accept multiple files, instead of starting a new instance for each file.

This is his scenario: His program is already open, perhaps editing a PHP 
file already, or perhaps without any files open. The user opens Explorer 
and double-clicks a PHP file. With the usual file-association rules, 
Windows will start a new instance of the application, passing the file 
name as a command-line parameter. But instead of editing that file in 
the new instance, which is what Andre's program already does, he wants 
to edit that file in the instance that was already open before.

One way to solve this is to change the file-association rules to use DDE 
instead of just a command line. Andre's program can then use Delphi's 
DDE components to accept commands from Windows to open another file.

The more common way to solve this is to have subsequent instances of the 
program detect that they aren't the first, and instead of continuing 
with their initialization sequence, they simply pass the file name along 
to the already-open instance and terminate. Detecting multiple instances 
is easy, and there are lots of examples in the newsgroup archives. There 
are slightly fewer examples of sending the new instance's command line 
to the old instance. I don't have time to explain it now, but I do it 
this evening if necessary.

I think hijacking the file association while the program is running is a 
bad idea. But I don't think it would affect anything in this case since 
it sounds like Andre's program is already associated with PHP files, so 
there's nothing to hijack.

-- 
Rob
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to