Mega Code Archive
Registering a file type on windows 9x-2000-nt
This is typically the task of an installer like Wise or InstallShield, buy you may be in a situation where you have to do it manually.
Registering an application to handle a certain file type means putting a few entries in the registry. Just use the function from the code below.
program RegisterExt;
uses
Registry;
procedure RegisterExtension(
const sAppName: String;
const sAppPath: String;
const sIconName: String;
const sExtension: String);
var
Reg: TRegistry;
begin { RegisterExtension }
Reg := TRegistry.Create;
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
OpenKey('.ext', True);
WriteString('', sAppName);
CloseKey;
OpenKey(sAppName, True);
WriteString('', sAppName);
OpenKey('DefaultIcon', True);
WriteString('', sIconName);
CloseKey;
OpenKey(sAppName+'\shell\open\command', True);
WriteString('', sAppPath);
CloseKey;
Free;
end { with Reg };
end; { RegisterExtension }
begin
RegisterExtension('MyGreatApplication',
'c:\program files\mystuff\myApp.exe',
'c:\program files\mystuff\myApp.ico',
'.shl');
end.