文件关联

var
    Reg: TRegistry;
    FileExt:String;
    FileType:String;
    MIMEType:String;
    ExecName:String;
begin
    FileExt:='.test';
    FileType:='Test File';
    MIMETYPE:='text/plain';
    ExecName:=Application.ExeName +' %1';

    if ParamCount>0 then
    begin
        self.Memo1.Lines.LoadFromFile(ParamStr(1));
    end
    else
    begin
        Reg := TRegistry.Create;
        Reg.RootKey :=HKEY_CLASSES_ROOT;
        Reg.OpenKey(FileExt, True);
        Reg.WriteString('', FileType);
        Reg.WriteString('Content Type', MIMEType);
        Reg.OpenKey('shell\open\command',True);
        Reg.WriteString('', ExecName);
        Reg.CloseKey;
        Reg.Free;
    end;
end;

你可能感兴趣的:(文件)