Solved

Loading Icons from Resource

Posted on 1998-11-10
2
141 Views
Last Modified: 2010-08-05
Hi All.  This is a simple question.  I want to be able to load some of the icons from SHELL32.DLL (found in the Windows' System directory).  This is what I have so far:

var ResDLL: THandle;
    P: Array[0..250] of Char;
    S: String;
    H: HIcon;

begin
   GetWindowsDirectory(P, SizeOf(P));
   S := StrPas(P);
   S := S + '\SYSTEM\SHELL32.DLL';
   StrPCopy(P, S);
   ResDLL := LoadLibrary(P);
   If ResDLL = 0 then begin
     ShowMessage('Failed to load DLL');
     Exit;
   End;
   H := LoadIcon(ResDLL, MakeIntResource(64));
   Image1.Picture.Icon.Handle := H;
   FreeLibrary(ResDLL);

The problem is, H (HIcon) is returning 0.  Any reason this is happening?

Regards,

Stuart.
0
Comment
Question by:Stuart_Johnson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1346379
Stuart Johnson

Replace the folloing line

H := LoadIcon(ResDLL, MakeIntResource(64)); //this returns an error : This is only available in Win32 mode...

with this

H := ExtractIcon(ResDLL, P, 0);//the 0 is the index of the icon you are looking for

Later
BoRiS
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1346380
Boris,

Man, you are quick :)  

Fantastic!

Stu
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question