procedure registerfiletype(ft,key,desc,icon,prg:string);
var myreg : treginifile;
ct : integer;
begin
// make a correct file-extension
ct := pos('.',ft);
while ct > 0 do begin
delete(ft,ct,1);
ct := pos('.',ft);
end;
if (ft = '') or (prg = '') then exit; //not a valid file-ext or ass. app
ft := '.'+ft;
try
myreg := treginifile.create('');
myreg.rootkey := hkey_classes_root; // where all file-types are described
if key = '' then key := copy(ft,2,maxint)+'_auto_file'; // if no key-name is given,
// create one
myreg.writestring(ft,'',key); // set a pointer to the description-key
myreg.writestring(key,'',desc); // write the description
if icon <> '' then
myreg.writestring(key+'/DefaultIcon','',icon); // write the def-icon if given
myreg.writestring(key+'/shell/open/command','',prg+' %1'); //association
finally
myreg.free;
end;
showmessage('File-Type '+ft+' associated with'#13#10+
prg+#13#10);
end;