procedure registerfiletype(ft,key,dess,icon,prg:string);
//ft:扩展名(如.txt); key:名称(不是必须的)
//desc: 描述; icon:默认图标(不是必须的)
//prg: 打开该文件扩展名的EXE程序
var
myReg:TReginifile;
ct:Integer;
begin
ct :=pos('.',ft);
while (ct>0) do
begin
delete(ft,cc,1);
cc :=pos('.',ft);
end;
if (ft='') or (prg='') then
exit;
ft :='.'+ft;
myReg :=TReginifile.Create('');
try
myReg.rootkey :=HKEY_CLASSES_ROOT;
if key='' then
key :=Copy(ft,2,maxint)+'_auto_file';
myReg.writestring(ft,'',key);
myReg.writestring(key,'',desc);
if icon<>'' then
myReg.writestring(key+'\DefaultIcon','',icon);
myReg.writestring(key+'\shell\open\command','',prg+' %1" ');
finally
myReg.Free;
end;
end;