Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi PrivateExtractIcons - einbinden & benutzen (https://www.delphipraxis.net/55494-privateextracticons-einbinden-benutzen.html)

Dj_Base 21. Okt 2005 20:12


PrivateExtractIcons - einbinden & benutzen
 
Hallo zusammen!

Ich möchte für mein Programm die Funktion PrivateExtractIcons nutzen.
Am besten wäre es, wenn das Icon dann in der gewählten Größe in einem TImage, oder Vergleichbarem erscheint.

Könnt ihr mir sagen, wie ich die Funktion richtig einbinde (Sie ist in \WINDOWS\System32\user32.dll enthalten) und wie ich mit ihr ein Icon z. B. in der Größe 64x64 extrahiere.
Ich habe bereits angefangen, doch habe ich noch einen kleinen Fehler bei der Einbindung und halt bei der Übergabe der Parameter an die Funktion.

Wäre super, wenn ihr mir kurz helfen könntet, :thumb:
Danke schön,

Gruß,
Dj_Base

Dj_Base 22. Okt 2005 16:35

Re: PrivateExtractIcons - einbinden & benutzen
 
Ich habe einige Infos vergessen:
Hier der Syntax der Funktion aus der MSDN Bibliothek (siehe hier)
Code:
UINT PrivateExtractIcons(
    LPCTSTR lpszFile,
    int nIconIndex,
    int cxIcon,
    int cyIcon,
    HICON *phicon,
    UINT *piconid,
    UINT nIcons,
    UINT flags
);
Und hier die Beschreibung der Parameter:

lpszFile
[in] Pointer to a null-terminated string that specifies the path and name of the file from which the icon(s) are to be extracted.
nIconIndex
[in] Specifies the zero-based index of the first icon to extract. For example, if this value is zero, the function extracts the first icon in the specified file.
cxIcon
[in] Horizontal icon size wanted. See remarks.
cyIcon
[in] Vertical icon size wanted. See remarks.
phicon
[out] Pointer to the returned array of icon handles.
piconid
[out] Pointer to a returned resource identifier for the icon that best fits the current display device. The returned identifier is 0xFFFFFFFF if the identifier is not available for this format. The returned identifier is 0 if the identifier cannot otherwise be obtained.
nIcons
[in] Specifies the number of icons to extract from the file. This parameter is only valid when extracting from .exe and .dll files.
flags
[in] Specifies flags that control this function. These flags are the LR_* flags used by the LoadImage function.

Könnt ihr mir sagen, wie ich die (oben aufgeführte) Funktion in mein Programm einbinde, und was ich der Funktion übergeben muss, wenn ich irgendein Icon mit der Größe 64x64 aus der shell32.dll haben möchte?

Wäre super, :thumb:
Danke schön & mfg

Dj_Base

Luckie 22. Okt 2005 17:03

Re: PrivateExtractIcons - einbinden & benutzen
 
Ich denke dafür ist Hier im Forum suchenSHGetFileInfo besser geeigent.

Dj_Base 22. Okt 2005 17:11

Re: PrivateExtractIcons - einbinden & benutzen
 
Jep, das hatte ich auch schon gehört.

Aber mit SHGetFileInfo kann man nur die LargeIcons(32x32), SmallIcons(16x16), ShellSmallIcons & LargeShellIcons extrahieren.
(Oder bin ich falsch informiert ?? :gruebel:)

ich bräuchte aber Größen von 16 bis zu 72 Pixel.

Könntest du/Könntet ihr mir trotzdem helfen? ;)

Gruß,
Dj_Base

Flocke 22. Okt 2005 17:26

Re: PrivateExtractIcons - einbinden & benutzen
 
Müsste ungefähr so aussehen:
Delphi-Quellcode:
function PrivateExtractIcon(lpszFile: PChar; nIconIndex, cxIcon, cyIcon: integer; phicon: PHandle; piconid: PDWORD; nIcons, flags: DWORD): DWORD; stdcall;
  external 'user32.dll' name 'PrivateExtractIconA';
... und aufrufen würdest du es mit:
Delphi-Quellcode:
var
  hIcon: THandle;
  nIconId: DWORD;
begin
  if PrivateExtractIcon('C:\WINDOWS\system32\shell32.dll', 0, 64, 64, @hIcon, @nIconId, 1, LR_LOADFROMFILE) = 1 then
    try
      DrawIcon(Picture1.Canvas.Handle, 0, 0, hIcon);
    finally
      DestroyIcon(hIcon);
    end;
end;
// Nachträge:

Die Stelle "64, 64" gibt die gewünschte Größe an.
Die 0 davor ist die Nummer des Icons (0 für das erste).
Das mit dem LR_LOADFROMFILE habe ich geraten - kann sein, dass du es weglassen musst.

Dj_Base 22. Okt 2005 17:36

Re: PrivateExtractIcons - einbinden & benutzen
 
Hi Flocke!

Das sieht genau nach der Antwort aus, die ich brauche, aber ein Problemchen ist da noch:
Man meldet mir nämlich jetzt bei Start des Programmes:
Der Prozedureinsprungspunkt 'PrivateExtractIconA' wurde in der DLL 'user32.dll' nicht gefunden.

Obwohl - ich habe bereits nachgesehen - 'PrivateExtractIconA' existiert sehrwohl in user32.dll!

Wer weiß Rat? ;)

mfg,
Dj_Base

Flocke 22. Okt 2005 18:50

Re: PrivateExtractIcons - einbinden & benutzen
 
Ziemlich blöd von mir :roll: - hab das 's' am Ende vergessen...
Delphi-Quellcode:
function PrivateExtractIcons(lpszFile: PChar; nIconIndex, cxIcon, cyIcon: integer; phicon: PHandle; piconid: PDWORD; nIcons, flags: DWORD): DWORD; stdcall;
  external 'user32.dll' name 'PrivateExtractIconsA';
... und in dem anderen Code natürlich auch.


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:59 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz