UsesRegistry;
FunctionRegisterfiletypecommand (fileextension, menuitemtext, target:String): Boolean;
VaR
Reg: Tregistry;
Filetype:String;
Begin
Result: = false;
Reg: = Tregistry. Create;
WithRegDo
Try
Rootkey: = hkey_classes_root;
IfOpenkey ('.' + fileextension, true)Then
Begin
Filetype: = readstring ('');
IfFiletype =''Then
Begin
Filetype: = fileextension + 'file ';
Writestring ('', filetype );
End;
Closekey;
IfOpenkey (filetype + '/Shell/' + menuitemtext + '/command', true)Then
Begin
Writestring ('', target + '" % 1 "');
Closekey;
Result: = true;
End;
End;
Finally
Free;
End;
End;
FunctionUnregisterfiletypecommand (fileextension, menuitemtext:String): Boolean;
VaR
Reg: Tregistry;
Filetype: string;
Begin
Result: = false;
Reg: = Tregistry. Create;
WithRegDo
Try
Rootkey: = hkey_classes_root;
IfOpenkey ('.' + fileextension, true)Then
Begin
Filetype: = readstring ('');
Closekey;
End;
IfOpenkey (filetype + '/shell', true)Then
Begin
Deletekey (menuitemtext );
Closekey;
Result: = true;
End;
Finally
Free;
End;
End;