Author: William Gerbert
Registering a file type on Windows 9x/2000/NT
Answer:
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.
1 program RegisterExt;
2 3 uses4 Registry;
5 6 procedure RegisterExtension(
7 const sAppName: string;
8 const sAppPath: string;
9 const sIconName: string;
10 const sExtension: string);
11 var12 Reg: TRegistry;
13 begin{ RegisterExtension }14 Reg := TRegistry.Create;
15 with Reg do16 begin17 RootKey := HKEY_CLASSES_ROOT;
18 OpenKey('.ext', True);
19 WriteString('', sAppName);
20 CloseKey;
21 OpenKey(sAppName, True);
22 WriteString('', sAppName);
23 OpenKey('DefaultIcon', True);
24 WriteString('', sIconName);
25 CloseKey;
26 OpenKey(sAppName + '\shell\open\command', True);
27 WriteString('', sAppPath);
28 CloseKey;
29 Free;
30 end{ with Reg };
31 end; { RegisterExtension }32 33 begin34 RegisterExtension('MyGreatApplication',
35 'c:\program files\mystuff\myApp.exe',
36 'c:\program files\mystuff\myApp.ico',
37 '.shl');
38 end.