高分求教,怎样更改文件关联?

xingjiaren 2002-06-22 09:59:52
如题!
...全文
46 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
stanely 2002-06-25
  • 打赏
  • 举报
回复
我怎么说也回答上来了人家需要的,你看看哪里不该给我分??
stanely 2002-06-25
  • 打赏
  • 举报
回复
那个叫:emu(ston) 的,xingjiaren马上给我分就是送嘛?

你找找,还有哪个贴子是送我分的??

csdn里面故意送分的难道少嘛?说别人怎么样,你自己就干净?

哦,有可能很干净,不然不会这么眼红的!
emu 2002-06-24
  • 打赏
  • 举报
回复
不要这样嘛,一分中就结贴?

http://www.csdn.net/Expert/forum.asp?typenum=8&searchKeys=+&roomid=0&author=xingjiaren&tabletype=now

给stanely送分也不是第一回了。

怎么你的帖子被删了那么多,信誉值还是100啊??
stanely 2002-06-22
  • 打赏
  • 举报
回复
function DeleteFileAssociation(Ext:string;Notify:boolean=true):boolean;
var
reg:tregistry;
key:string;
label
final;
begin
result:=false;
key:='';
if ext='' then exit;
if ext[1]<>'.' then ext:='.'+ext;
try
reg:=tregistry.Create;
reg.RootKey:=hkey_classes_root;
if reg.KeyExists(ext) then
begin
if reg.OpenKey(ext,false) then
begin
key:=reg.ReadString('');
reg.CloseKey;
if (not reg.DeleteKey(ext)) or (not reg.DeleteKey(key)) then
goto final;
end
else
goto final;
end;
if notify then
// SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
notifyassociationchange;
result:=true;
final:
finally
reg.Free;
end;
end;
function SetFileAssociation(Ext:string;
OpenApp:string;
FileTypeDescription:string='';
OpenMenuCaption:string='';
IconFile:string='';
IconIndex:integer=0;
Notify:boolean=true):boolean;
var
reg:tregistry;
key:string;
label
final;
begin
result:=false;
if ext='' then exit;
if ext[1]<>'.' then ext:='.'+ext;
if openmenucaption='' then openmenucaption:='&Open';
if IconFile='' then IconFile:=openapp;
key:=copy(ext,2,length(ext))+' File';
if filetypedescription='' then filetypedescription:=key;

//////////////////////////////////////////
try
reg:=tregistry.Create;
reg.RootKey:=hkey_classes_root;
if reg.OpenKey(ext,true) then
begin
reg.WriteString('',key);
reg.CloseKey;
end
else
goto final;
if reg.OpenKey(key,true) then
begin
reg.WriteString('',filetypedescription);
reg.CloseKey;
end
else
goto final;
if reg.OpenKey(key+'\DefaultIcon',true) then
begin
reg.WriteString('',openapp+','+inttostr(iconindex));
reg.CloseKey;
end
else
goto final;
if reg.OpenKey(key+'\Shell\Open',true) then
begin
reg.WriteString('',openmenucaption);
reg.CloseKey;
end
else
goto final;
if reg.OpenKey(key+'\Shell\Open\Command',true) then
begin
reg.WriteString('','"'+openapp+'" "%1"');
reg.CloseKey;
end
else
goto final;
if notify then
notifyassociationchange;
result:=true;
final:
finally
reg.Free;
end;
end;
procedure NotifyAssociationChange;
begin
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
end;

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧