首页  编辑  

根据扩展名取得相关图标

Tags: /超级猛料/Stream.File.流、文件和目录/Shell操作/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` function GetIconFromExt(ext:string;var filename:string;var index:integer):boolean;

var

reg:tregistry;

src:string;

begin

reg:=tregistry.create;

reg.RootKey:=hkey_classes_root;

result:=reg.OpenKey('.'+ext,false);

if result then

begin

  src:=reg.ReadString('');

  reg.CloseKey;

  if reg.OpenKey(src+'\defaulticon',false) then

  begin

    src:=reg.ReadString('');

    if pos('%1',src)<>0 then exit;

    filename:=copy(src,0,pos(',',src)-1);

    index:=strtoint((trim(copy(src,pos(',',src)+1,length(src)-pos(',',src)))));

  end;

end;

reg.Free;

end;