Andre van Zuydam is right. This is what you need.

I use this procedure:


procedure AssociateWith(const FileExtension, AsociationName: string);           
{ EXAMPLU:
FileExtension:= '.txt' /  AsociationName:= 'Metapad' }
var _file: string; {trebuie sa inceapa cu . }
begin
 _file:= FileExtension+ '_file';
 WriteReg_String(HKEY_CLASSES_ROOT, FileExtension, '', _file,   TRUE, TRUE);
 WriteReg_String(HKEY_CLASSES_ROOT, _file, '', AsociationName,  TRUE, TRUE);
 WriteReg_String(HKEY_CLASSES_ROOT, _file+'\shell', '', 'open', TRUE, TRUE);
 WriteReg_String(HKEY_CLASSES_ROOT, _file+'\shell\open\command', '', 
Application.ExeName+ ' "%1"',
TRUE, TRUE);
 WriteReg_String(HKEY_CLASSES_ROOT, _file+'\DefaultIcon'       , '', 
Application.ExeName,         
TRUE, TRUE);
end;



And this is my WriteReg_String:

function WriteReg_String(sRootKey: HKEY; sKeyPath, sKeyName,
                         sValue: string; bLazy, bCanCreate: boolean): boolean;  
{scrie in registri
un string la adresa specificata}
VAR
 Rg: TRegistry;
begin
 result:= False;
 Rg:= TRegistry.Create;
 Rg.RootKey:= sRootKey;
 Rg.LazyWrite:= bLazy;
 try
  if Rg.OpenKey(sKeyPath, bCanCreate) then
  BEGIN
   Rg.WriteString(sKeyName, sValue);
   Result:= True;   
  END
 finally
  Rg.Free;
 end; 
end;











--- "Malcolm J. Kudra" <[EMAIL PROTECTED]> 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?
> 
> HTH,
> Malcolm
> __________________________________________________
> Delphi-Talk mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi-talk
> 


...and the traveler died, stroked by the beauty of the landscape.

THE MORNING OF THE MAGICIANS
Louis Pawels & Jacques Bergier


                
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 

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

Reply via email to