From: Kerstin Thaler Subject: Re: Handles & icons Date: 14 Jul 1999 00:00:00 GMT Message-ID: <378C1A76.EB681CC3@t-online.de> Content-Transfer-Encoding: 7bit References: <378B3D9A.522D3B70@correo.uniovi.es> <378B88E5.406CE841@t-online.de> <7mgt7i$1n74@forums.borland.com> X-Accept-Language: de,en-US Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.delphi.graphics To get both you can try this: procedure TForm1.FormPaint(Sender: TObject); var LargeIcon: HIcon; SmallIcon: HIcon; IconCount: Integer; i: Integer; FileName: PChar; begin FileName := 'C:\WINNT\REGEDIT.EXE'; IconCount := ExtractIconEx(FileName, -1, LargeIcon, SmallIcon, 0); for i := 0 to Pred(IconCount) do begin ExtractIconEx(FileName, i, LargeIcon, SmallIcon, 1); DrawIcon(Canvas.Handle, 5 + i * 36, 5, LargeIcon); DrawIconEx(Canvas.Handle, 5 + i * 36, 50, SmallIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL); end; end; It draws a stripe with all large icons contained in a file and below of that a stripe with all small icons. In the other example HINSTANCE is the handle of the calling application, not of the called. So it's not necessary that the application which you want to draw the icons of must be opened. Kerstin Paul Nicholls wrote: > > Hi Kerstin, does the code you wrote below retrieve the small icon or the > large icon? If it retrieves one of these types, can the other be retrieved > as well? I want to get both the small and large icons from a file. There > is another slight hassle; the files I want to get the icons from won't > necessarily be running so there won't be a HINSTANCE for them, so this means > I can't use the exact code below...thanks in advance. > > >procedure TForm1.FormPaint(Sender: TObject); > >var > > Icon: TIcon; > >begin > > Icon := TIcon.Create; > > try > > Icon.Handle := ExtractIcon(HINSTANCE, 'C:\WINNT\REGEDIT.EXE', 0); > > Canvas.Draw(10, 10, Icon); > > finally > > Icon.Free; > > end; > >end; > > -- > Paul Nicholls. > ******************************************************** > Live long and optimise > -------------------------------- > Web Page : www.southcom.com.au/~phantom