ConfigExt.~pas
上传用户:mjqmds
上传日期:2022-05-05
资源大小:2827k
文件大小:7k
- unit ConfigExt;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, CheckLst, TFlatButtonUnit, XPMenu,
- TFlatCheckListBoxUnit, StrUtils;
- type
- TCEForm = class(TForm)
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- RadioButton3: TRadioButton;
- FlatCheckListBox1: TFlatCheckListBox;
- XPMenu1: TXPMenu;
- FlatButton1: TFlatButton;
- FlatButton2: TFlatButton;
- procedure RadioButton1Click(Sender: TObject);
- procedure RadioButton2Click(Sender: TObject);
- procedure RadioButton3Click(Sender: TObject);
- procedure FlatButton1Click(Sender: TObject);
- procedure FlatButton2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- procedure UpdateRegister(bLoad:Boolean=false);
- procedure CustomSelects(b:Boolean; Exts:String);
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- CEForm: TCEForm;
- implementation
- uses Main, RegFiles;
- {$R *.dfm}
- function GetExt(Str:String):String;
- Var
- Index:Integer;
- begin
- Index:=Pos('->',Str);
- Result:=Copy(Str,1,Index-1);
- Result:=Trim(Result);
- end;
- function GetIconIndex(Ext:String):Integer;
- begin
- Result:=2;
- Ext:=UpperCase(Trim(Ext));
- if Ext='.ASF' then
- Result:=1
- else if Ext='.AVI' then
- Result:=3
- else if Ext='.BF' then
- Result:=4
- else if Ext='.DAT' then
- Result:=5
- else if Ext='.DVD' then
- Result:=6
- else if Ext='.SWF' then
- Result:=7
- else if Ext='.WPL' then
- Result:=8
- else if Ext='.M4B' then
- Result:=9
- else if Ext='.M4P' then
- Result:=10
- else if Ext='.M4V' then
- Result:=11
- else if Ext='.MKV' then
- Result:=12
- else if Ext='.MP3' then
- Result:=13
- else if Ext='.MP4' then
- Result:=14
- else if Ext='.MPEG' then
- Result:=15
- else if Ext='.MPG' then
- Result:=16
- else if Ext='.OGM' then
- Result:=17
- else if Ext='.PSS' then
- Result:=18
- else if Ext='.PVA' then
- Result:=19
- else if Ext='.MOV' then
- Result:=20
- else if (Ext='.RM') OR (Ext='.RMVB') then
- Result:=21
- else if Ext='.TP' then
- Result:=22
- else if Ext='.TPR' then
- Result:=23
- else if Ext='.TS' then
- Result:=24
- else if Ext='.VOB' then
- Result:=25
- else if Ext='.WM' then
- Result:=26
- else if Ext='.WMA' then
- Result:=27
- else if Ext='.WMP' then
- Result:=28
- else if Ext='.MMV' then
- Result:=29
- end;
- procedure TCEForm.CustomSelects(b: Boolean; Exts:String);
- Var
- i:Integer;
- Tmp:String;
- begin
- Exts:=UpperCase(Exts);
- For i:=0 to FlatCheckListBox1.Items.Count-1 do
- begin
- Tmp:=UpperCase(GetExt(FlatCheckListBox1.Items.Strings[i]));
- if AnsiPos(Tmp,Exts)<>0 then
- FlatCheckListBox1.Checked[i]:=b
- else
- FlatCheckListBox1.Checked[i]:=Not b;
- end;
- end;
- procedure TCEForm.RadioButton1Click(Sender: TObject);
- begin
- CustomSelects(true,'.RM,.RMVB,.AVI,.WMV,.ASF,.DAT,.VOB,.MPG,.MKV,.MOV,.MP3,.WMA,.WAV,.WPL');
- end;
- procedure TCEForm.RadioButton2Click(Sender: TObject);
- begin
- CustomSelects(true,'.RM,.RMVB,.AVI,.WMV,.ASF,.DAT,.VOB,.MPG,.MKV,.MOV,.WPL');
- end;
- procedure TCEForm.RadioButton3Click(Sender: TObject);
- begin
- CustomSelects(true,'.MP3,.WMA,.WAV,.WPL');
- end;
- procedure TCEForm.FlatButton1Click(Sender: TObject);
- Var
- i:Integer;
- Str:String;
- begin
- For i:=0 to FlatCheckListBox1.Items.Count-1 do
- begin
- if FlatCheckListBox1.Checked[i] then
- begin
- if Str='' then
- Str:=FlatCheckListBox1.Items[i]
- else
- Str:=Str+','+FlatCheckListBox1.Items[i];
- end;
- end;
- if RadioButton1.Checked then
- Str:=RadioButton1.Name+','+Str
- else if RadioButton2.Checked then
- Str:=RadioButton2.Name+','+Str
- else
- Str:=RadioButton3.Name+','+Str;
- MainForm.WriteIni('Play','Exts',Str);
- UpdateRegister;
- ModalResult:=mrok;
- end;
- procedure TCEForm.UpdateRegister(bLoad:Boolean=false);
- Var
- i:Integer;
- Str,Tmp:String;
- StrList:TStringList;
- Var
- Radio:TRadioButton;
- begin
- StrList:=TStringList.Create;
- Try
- if bLoad then
- begin
- Str:=UpperCase(MainForm.ReadIni('Play','Exts',''));
- StrList.Text:=AnsiReplaceStr(Str,',',#13#10);
- if StrList.Count=0 then
- begin
- Radio:=RadioButton1;
- Radio.Checked:=true;
- Radio.OnClick(Radio);
- end
- else
- begin
- Radio:=TRadioButton(Self.FindComponent(StrList.Strings[0]));
- Radio.Checked:=true;
- Radio.OnClick(Radio);
- end;
- end;
- For i:=0 to FlatCheckListBox1.Items.Count-1 do
- begin
- Tmp:=UpperCase(GetExt(FlatCheckListBox1.Items[i]));
- if bLoad then
- begin
- FlatCheckListBox1.Checked[i]:=Pos(Tmp,Str)<>0;
- end;
- if FlatCheckListBox1.Checked[i] then
- begin
- CreateAssociation(Tmp,Application.ExeName,Application.ExeName+','+IntToStr(GetIconIndex(ExtractFileExt(Tmp))),
- 'WHSUPPERPLAY'+Tmp,'老王的超级播放器',false);
- end
- else
- RemoveAssociation(Tmp,'WHSUPPERPLAY'+Tmp,
- true,false);
- end;
- Finally
- StrList.Free;
- end;
- if Not bLoad then
- CreateAssociation('','','','','',true);
- end;
- procedure TCEForm.FlatButton2Click(Sender: TObject);
- begin
- ModalResult:=mrCancel;
- end;
- procedure TCEForm.FormCreate(Sender: TObject);
- Var
- i:Integer;
- begin
- FlatCheckListBox1.Items.Add('.RM ->视频文件');
- FlatCheckListBox1.Items.Add('.RMVB ->视频文件');
- FlatCheckListBox1.Items.Add('.AVI ->视频文件');
- FlatCheckListBox1.Items.Add('.WMV ->视频文件');
- FlatCheckListBox1.Items.Add('.ASF ->视频文件');
- FlatCheckListBox1.Items.Add('.DAT ->视频文件');
- FlatCheckListBox1.Items.Add('.VOB ->视频文件');
- FlatCheckListBox1.Items.Add('.MPG ->视频文件');
- FlatCheckListBox1.Items.Add('.MKV ->视频文件');
- FlatCheckListBox1.Items.Add('.MOV ->视频文件');
- FlatCheckListBox1.Items.Add('.MP3 ->声音文件');
- FlatCheckListBox1.Items.Add('.WMA ->声音文件');
- FlatCheckListBox1.Items.Add('.WAV ->声音文件');
- FlatCheckListBox1.Items.Add('.WPL ->播放列表文件');
- UpdateRegister(true);
- for i:=0 to FlatCheckListBox1.Items.Count-1 do
- begin
- if FlatCheckListBox1.Checked[i] then
- Exit;
- end;
- RadioButton1.OnClick(RadioButton1);
- end;
- end.