Mega Code Archive
To Register Associate a file type with your application
Title: to Register Associate a file type with your application
Question: How to Register the Associate of a file type with your application
Answer:
Var
Reg : TRegistry;
Begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
OpenKey('\MyApp', True);
WriteString('', 'MyApp File');
CloseKey;
OpenKey('MyApp\DefaultIcon', True);
// The first parameter below MUST be a blank string
// The last parameter is the icon in your EXE file to use.
WriteString('', Application.ExeName + ',0');
CloseKey;
OpenKey('MyApp\shell\open\command', True);
WriteString('', Application.ExeName + ' "%1"');
CloseKey;
RootKey := HKEY_CLASSES_ROOT;
OpenKey('\.ext', True); //substitute .ext with
//the extension you desire
WriteString('', 'MyApp');
CloseKey;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
End;