文件关联<br> <br>uses<br><br>registry, shlobj;<br><br>procedure TForm1.RegisterFileType(prefix: string; exepfad: string);<br><br>var<br><br>reg: TRegistry;<br><br>begin<br><br>reg := TRegistry.Create;<br><br>try<br><br>reg.RootKey := HKEY_CLASSES_ROOT;<br><br>//create a new key --> .pci<br><br>reg.OpenKey('.' + prefix, True);<br><br>try<br><br>//create a new value for this key --> pcifile<br><br>reg.Writestring('', prefix + 'file');<br><br>finally<br><br>reg.CloseKey;<br><br>end;<br><br>//create a new key --> pcifile<br><br>reg.CreateKey(prefix + 'file');<br><br>//create a new key pcifile<br><br>reg.OpenKey(prefix + 'file', True);<br><br>//and create a value where the icon is stored --> c:.exe,0<br><br>try<br><br>reg.Writestring('', exepfad + ',0');<br><br>finally<br><br>reg.CloseKey;<br><br>end;<br><br>reg.OpenKey(prefix + 'file', True);<br><br>//create value where exefile is stored --> c:.exe "%1"<br><br>try<br><br>reg.Writestring('', exepfad + ' "%1"');<br><br>finally<br><br>reg.CloseKey;<br><br>end;<br><br>finally<br><br>reg.Free;<br><br>end;<br><br>SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);<br><br>end;<br><br> <br><br>procedure TForm1.Button1Click(Sender: TObject);<br><br>begin<br><br>RegisterFileType('txt', '你的执行文件如:c:/edit.exe');<br><br>end;<br><br>我希望你是知道执行文件还得处理ParamStr