procedure RegisterAssociation (strExt, strType : STRING);
var
reg : TRegistry;
szFileName : array[0..500] of CHAR;
begin
reg := TRegistry.Create;
try
with reg do
begin
RootKey := HKEY_CLASSES_ROOT;
if (OpenKey (strExt, TRUE)) then
WriteString ('', strType);
CloseKey;
GetModuleFileName (0, szFileName, sizeof(szFileName));
RootKey := HKEY_CLASSES_ROOT;
if (OpenKey (strType, TRUE)) and
(OpenKey ('shell', TRUE)) and
(OpenKey ('Register',TRUE)) and
(OpenKey ('command', TRUE)) then
WriteString ('', '"' + STRING(szFileName) + '" /reg "%1"');
CloseKey;
RootKey := HKEY_CLASSES_ROOT;
if (OpenKey (strType, TRUE)) and
(OpenKey ('shell', TRUE)) and
(OpenKey ('Unregister',TRUE)) and
(OpenKey ('command', TRUE)) then
WriteString ('', '"' + STRING(szFileName) + '" /unreg "%1"');
CloseKey;
end; { with reg do }
finally
reg.Free;
end;
end; { RegisterAssociation }