Solved

Loading Icons from Resource

Posted on 1998-11-10
2
142 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 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