English 中文(简体)
5. 自助食堂补贴 信息 W 职能
原标题:Substitute for SHGetFileInfoW function

I m与SHGetFileInfoW有问题,使用Im。

它的开端(启动)消耗量非常缓慢,第一次读到100米。

在MSDN中,它应当从深处读到,而不是主要透镜,因为它可能阻碍进程。

我想利用其他一些职能,如果有的话,读一读一下。

另一回事。 如何阅读大语,目前我可以读到多达32x32(SHGFI_LARGEICON)。

Thanks!

实际守则:

procedure TForm1.LoadIcons;
var
  Info:     TShFileInfo;
  Icon:     TIcon;
  Flags:    UINT;
  FileName: PAnsiChar;

begin
  FileName :=  .txt ;
  Flags := SHGFI_USEFILEATTRIBUTES or SHGFI_ICON or SHGFI_LARGEICON;
  Icon := TIcon.Create;
  try
    SHGetFileInfo(FileName, FILE_ATTRIBUTE_NORMAL, Info,
      SizeOf(Info), Flags);
    Icon.Handle := Info.hIcon;
    Image1.Picture.Assign(Icon);
    Image1.Refresh;
  finally
    DestroyIcon(Info.hIcon);
    Icon.Free;
  end;
end;
最佳回答

您可找到关于从书记官处申请延期的<代码>DefaultIcon,并使用ExtractIconEx rel=“nofollow>。 这方面的一个例子是

我不知道它是否比<条码>更快。 SHGetFileInfo

http://www.un.org。

I have extracted (from the sample) the part which gets the ICON from the Extension. It actually works very fast. could be optimized more. (I modified the code a bit):

// find the icon for a certain file extension in the registry
function TForm1.RegistryIconExtraction(Extension : string): integer;
var
    RegKey : TRegistry;
    IconPos : integer;
    AssocAppInfo : string;
    ExtractPath, FileName : string;
    IconHandle, PLargeIcon, PSmallIcon : HICON;
    AnIcon : TIcon;

begin
  Result := 0; // default icon

  if Extension[1] <>  .  then Extension :=  .  + Extension;

  RegKey := TRegistry.Create(KEY_READ);
  try
    // KEY_QUERY_VALUE grants permission to query subkey data.
    RegKey.RootKey := HKEY_CLASSES_ROOT; // set folder for icon info lookup
    if RegKey.OpenKeyReadOnly(Extension) then // extension key exists?
    try
      AssocAppInfo := RegKey.ReadString(  );  // read app key
      RegKey.CloseKey;
    except
      Exit;
    end;
    if ((AssocAppInfo <>   ) and  // app key and icon info exists?
      (RegKey.OpenKeyReadOnly(AssocAppInfo +  DefaultIcon ))) then
    try
      ExtractPath := RegKey.ReadString(  ); // icon path
      RegKey.CloseKey;
    except
       Exit;
    end;
  finally
    RegKey.Free;
  end;

  // IconPos after comma in key  ie: C:Program FilesWinzipWinzip.Exe,0
  // did we get a key for icon, does IconPos exist after comma seperator?
  If ((ExtractPath <>   ) and (pos( , , ExtractPath) <> 0)) then
  begin

    // Filename in registry key is before the comma seperator
    FileName := Copy(ExtractPath, 1, Pos( , , ExtractPath) - 1);
    // extract the icon Index from after the comma in the ExtractPath string
    try
      IconPos := StrToInt(copy(ExtractPath, Pos( , , ExtractPath) + 1,
        Length(ExtractPath) - Pos( , , ExtractPath) + 1));
    except
      Exit;
    end;

    IconHandle := ExtractIconEx(PChar(FileName), IconPos, PLargeIcon, PSmallIcon, 1);

    If (PLargeIcon <> 0) then
    begin
      AnIcon := TIcon.Create;
      AnIcon.Handle := PLargeIcon;

      Image1.Picture.Assign(AnIcon);
      Image1.Refresh;

      AnIcon.Free;
    end;

    DestroyIcon(PLargeIcon);
    DestroyIcon(PSmallIcon);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  t1, t2: DWORD;
begin
  t1 := GetTickCount;
  RegistryIconExtraction( .txt );
  t2 := GetTickCount;
  Memo1.Lines.Add(IntToStr(t2-t1));
end;

<><> ><>>> 样本代码现已符合Vista/Win7 UAC。

问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签