Link to home
Start Free TrialLog in
Avatar of Stuart_Johnson
Stuart_Johnson

asked on

Loading Icons from Resource

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.
ASKER CERTIFIED SOLUTION
Avatar of BoRiS
BoRiS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stuart_Johnson
Stuart_Johnson

ASKER

Boris,

Man, you are quick :)  

Fantastic!

Stu