const
cMyExe = '.avi';
//文件扩展名
procedure TForm1.FormCreate(Sender: TObject);//注册文件关联
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey :=HKEY_CLASSES_ROOT;
// Reg.OpenKey(cMyExe+'/DefaultIcon', True);
// Reg.WriteString('', Application.ExeName + ',0');
reg.OpenKey(cMyExe,true);
reg.WriteString('','myfile');
Reg.CloseKey;
Reg.OpenKey('myfile/shell/open/command', True);
Reg.WriteString('',Application.ExeName + ' %1');
Reg.CloseKey;
finally
Reg.Free;
end;
end;
procedure TForm1.MediaPlay(PlayFile: string);
begin
with mediaplayer1do
begin
FileName:=PlayFile;
AutoEnable:=true;
AutoRewind:=true;
Open;
Play;
end;
end;
procedure TForm1.FormShow(Sender: TObject);//程序启动时播放
begin
if paramstr(1)<>'' then
MediaPlay(paramstr(1));
end;