delphi 获取系统注册的文件图标


本文整理自网络,侵删。

 var
  Icon:TICON;
  Key : string;
  App : string;
  Index : Integer;
begin
  FileName:=Edit6.Text;
  if Pos('.',FileName) < 0 then
  begin
    Exit;
  end;
  with TRegistry.Create do
  try
    RootKey:=HKEY_CLASSES_ROOT;
    Key:=ExtractFileExt(FileName);
    if KeyExists(Key) then
    begin
      OpenKey(Key,false);
      Key:=ReadString(#);
      CloseKey;
    end;
    if Key<>''
then
    begin
      RootKey:=HKEY_CLASSES_ROOT;
      if KeyExists(Key) then
      begin
        OpenKey(Key,false);
        OpenKey('DefaultIcon',false);
        Key:=ReadString(#);
        CloseKey;
      end;
    end;
  finally
    free;
  end;
  if Key<>'' then
  begin
    Icon:=TIcon.Create;
    App:='';
    Index :=0;
    If Pos(',',Key) > 0 then
    begin
      App :=Copy(Key,1,Pos(',',Key)-1);
      try
        Index :=StrToInt(Copy(Key,Pos(',',Key)+1,Length(Key)));
      except
        Index :=0;
      end;
    end;
    if App<> '' then
    begin
      Icon.Handle:=ExtractIcon( HINSTANCE,PChar(App),Index);
      Form1.Icon:=Icon;
    end;
    Icon.Free;
  end;
  Edit5.Text := Key;
end;

相关阅读 >>

Delphi 在窗体上创建自己的光标并输入文字

Delphi 删除internet临时文件

Delphi 获取计算机名和用户名

Delphi 实现打开文件定位

Delphi控制程序在任务栏显示与隐藏

Delphi 控制台关闭指定窗口

Delphi 在ms access数据库中图像的存储和显示

最简单的Delphi驱动结束进程

Delphi 搜索指定目录下的文件

Delphi 相对路径和绝对路径的转换

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...