Показать сообщение отдельно
  #1  
Старый 29.04.2014, 01:14
HTTqp HTTqp вне форума
Новичок
 
Регистрация: 16.04.2014
Сообщения: 77
Версия Delphi: Delphi 7
Репутация: -25
По умолчанию Ico из реестра

Как вытащить иконку из реестра?
Делаю так но не работает:
Код:
function GetRegistryIconHandle(FileName: string): HICON;
var
  R: TRegistry;
  Alias, //псевдвним для расширения в реестре
 IconPath: string; //путь для файла с иконкой
 IconNum, //номер иконки в файле
 QPos: Integer; //позиция запятой в записи реестра
begin
  IconNum := 0;
  R := TRegistry.Create;    
  try
    R.RootKey := HKEY_CLASSES_ROOT;
    if R.OpenKey('\' + ExtractFileExt(FileName), True) then
      Alias := R.ReadString('');
    R.CloseKey;
    if R.OpenKey('\' + Alias + '\DefaultIcon', True) then
      IconPath := R.ReadString('');
    R.CloseKey;
    QPos := Pos(',', IconPath);
    if QPos <> 0 then
    begin
      IconNum := StrToInt(Copy(IconPath, QPos + 1, 4));
      IconPath := Copy(IconPath, 1, QPos - 1)
    end;
  finally
    R.Free;
  end;
  Result := ExtractIcon(hInstance, PChar(IconPath), IconNum);
end;
Ответить с цитированием