Windows - associando arquivos no explorer

Top  Previous  Next

Associando uma extensao de arquivo

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

 

var

  Reg1 : TRegistry;

 

Begin

  Reg1 := TRegistry.Create;

  With Reg1 do

  begin

       RootKey := HKEY_CLASSES_ROOT;

 

       // Cria a extensao .tex e sua chave...

       OpenKey( '\.tex', True );

       WriteString( '''Textinho_Pequeno' );

 

       // Propriedades da extensao através da chave criada ali em cima

       OpenKey( '\Textinho_Pequeno', true);

       WriteString( '''Textinho pequeno' );

 

       // Programa associado, não esquecer o \"%1\"

       OpenKey( '\Textinho_Pequeno\shell\open\command', true);

       WriteString( '''C:\FILE\TT.EXE %1' );

 

       // Ícone

       OpenKey( '\Textinho_Pequeno\DefaultIcon', true);

       WriteString( '''C:\FILE\TT.EXE,1' );

 

       Free;

  end;

end;

 

 

Removendo a Associacao

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

var

  Reg1 : TRegistry;

Begin

  Reg1 := TRegistry.Create;

  With Reg1 do

  begin

       RootKey := HKEY_CLASSES_ROOT;

       DeleteKey( '\.tex' );

       DeleteKey( 'Textinho_Pequeno' );

       Free;

  end;

end;