Solved

Loading Icons from Resource

Posted on 1998-11-10
2
136 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 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now