?
Solved

Loading Icons from Resource

Posted on 1998-11-10
2
Medium Priority
?
147 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
2 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

755 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