All pastes #277590 Raw Edit

Someone

public text v1 · immutable
·published 2006-12-13 11:10 UTC
rendered paste body
procedure CopyOldFiletype(Ext: string; NewFiletype: string);
var
  OldFiletype: string;
  OldIcon: string;
  OldApp: string;
begin
  if RegKeyExists(HKCR, '.' + Ext) then
    begin
      RegQueryStringValue(HKCR, '.' + Ext, '', OldFiletype);
      if OldFiletype <> NewFiletype then
        begin
          if RegQueryStringValue(HKCR, OldFiletype + '\DefaultIcon', '', OldIcon) then
            RegWriteStringValue(HKCR, NewFiletype + '\DefaultIcon', '', OldIcon);

          if RegQueryStringValue(HKCR, OldFiletype + '\shell\open\command', '', OldApp) then
            begin
              RegWriteStringValue(HKCR, NewFiletype + '\shell\open', '', '&Open');
              RegWriteStringValue(HKCR, NewFiletype + '\shell\open\command', '', OldApp);
            end;
          if RegQueryStringValue(HKCR, OldFiletype + '\shell\Play\command', '', OldApp) then
            begin
              RegWriteStringValue(HKCR, NewFiletype + '\shell\Play', '', '&Play');
              RegWriteStringValue(HKCR, NewFiletype + '\shell\Play\command', '', OldApp);
            end;
        end;
    end;
end;

procedure CopyOldFiletypes;
begin
  CopyOldFiletype('mkv', 'MatroskaVideo');
  CopyOldFiletype('mp4', 'mp4file');
  CopyOldFiletype('ogm', 'ogmfile');
end;