Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get system icons under NT

Posted on 1998-03-26
20
Medium Priority
?
214 Views
Last Modified: 2010-04-06
Hi,
Like the title says ;)
I'm currently using something like sicons.handle:=shgetfileinfo('', ect . I don't remember exactly
but it is working, under 95 ar least.
Why it is not working under NT, how should I do ?
I want a tlistimage containing the system icon list.
0
Comment
Question by:jeurk
[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
  • 11
  • 9
20 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1360888
Hi friend,

it is as follows:

procedure GetSysIcons;
var
 SysImList: HImageList;
 SFI: TSHFileInfo;
begin
  Images := TImageList.Create(Self); //This var should be declared in unit scope
  SysImList := SHGetFileInfo('', 0, SFI, SizeOf(SFI), SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
  if SysImList <> 0 then begin
    Images.Handle := SysImList;
    Images.ShareImages := TRUE;  // DON'T FREE THE SYSTEM IMAGE LIST!!!!!
  end;
end;

and DO NOT FORGET TO call Image.Free upon terminating


Regards,
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360889
thank for the suggestion
It will take me probably until monday to check this out.
So please be patient with grade ;)
Jeurk
0
 
LVL 5

Expert Comment

by:inter
ID: 1360890
No problem,

But if you do not have Delphi 3 be sure you have ShellObj.pas for interfacing shell functionality.

Bye,
Igor
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Author Comment

by:jeurk
ID: 1360891
Hi,
I tryed the thing, but it is not working under NT4.
I was already doing something similar anyway:

           Images.Handle :=  := SHGetFileInfo('', 0, SFI, SizeOf(SFI), SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
           Images.ShareImages := TRUE;  

Do you have NT ?
maybe you could make litle prog that shows a drive icon, that you will check out on NT4
and give it over to me.
I will add some points if you need them ;)
Jeurk

PS:maybe what you sayd works, but I made something other wrong.
0
 
LVL 5

Expert Comment

by:inter
ID: 1360892
I tried this on NT with Delphi 2.0 and it work. Bind form1click to the forms click method. Run it and click on form.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
uses ShellApi;

var
  Images : TImageList;

procedure GetSysIcons;
var
 SysImList: THandle;
 SFI: TSHFileInfo;
begin
  Images := TImageList.Create(nil); //This var should be declared in unit scope
  SysImList := SHGetFileInfo('', 0, SFI, SizeOf(SFI), SHGFI_SYSICONINDEX or
SHGFI_LARGEICON);//replace this with SHGFI_SMALLICON for retreving small icons
  if SysImList <> 0 then begin
    Images.Handle := SysImList;
    Images.ShareImages := TRUE;  // DON'T FREE THE SYSTEM IMAGE LIST!!!!!
  end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  GetSysIcons;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Images.Free;
end;

procedure TForm1.FormClick(Sender: TObject);
var
  i,x,y : integer;
begin
  for i := 0 to Images.Count - 1 do
  begin
    x := i*32 mod Form1.ClientWidth;
    y := (i*32 div Form1.ClientWidth)*32;
    Images.Draw(Canvas,x,y,i);
  end;
end;

end.


Regards,
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360893
Always connected, as I can see ;)
I'll try it out, thanks.
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360894
Bad news my friend,

It is working perfectly under 95 as always.But under NT4 service pack 3 French version.
There is only one icon that appear!!!
It's a standard folder icon. Nothing more.
What you think now. ?
0
 
LVL 5

Expert Comment

by:inter
ID: 1360895
Ok then,

I withdraw until I (or somebody else) find(s) a solution.

Regards,
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360896
The nt I used was not mine, but a friend.
Let say, I'm gonna try to install the ****ing thing
and try out by myself.
You swear that it is working under NT4 ?
Which service pack ?

John.
0
 
LVL 5

Expert Comment

by:inter
ID: 1360897
I have runining NT English US ServicePack3. To day I try something else, namely try to obtain the association list(extract which icon is associated with which extension + sysimage list from the coresponding resource file). This should solve the problem on all versions of windows95+ and WindowsNt3.x+. So, before I swear for it(though I have received about 2 dozen icons with above method) I want to work more.

By the way WHERE ARE THE OTHER EXPERTS???? Come on please lets solve this.

Regards,
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360898
Hello inter,

Thanks for being still here ;)
I have a component that lists all the logical drives avalaible,
my friend says that it is working under nt.
Would you take a look at it, and find out why this is working
and not what we tryed ?
I took a look at it, but I must not be smart enough ;)
What you think ?
John
0
 
LVL 5

Expert Comment

by:inter
ID: 1360899
If the copyright is not problem and the component has source sure I want:

inter@kosgeb.tekmer.gov.tr

By the way, all the icons we want and more are in the resource of Shell32.dll in system directory. I may try to extract them for you, or just fetch the ones that need to be used and combine a resource file which is then read into an imagelist. This solution sure works every where but since are not dynamic does not change with system changes(for example desktop themes for win95 which changes all the icons etc)

Regards,
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360900
No, don't extract them from shell32.
It's not what I want. Cause if the user has personnalysed his icons,
my prog won't reflect the changes, You see ?
I just sent the thing.
CU

0
 
LVL 5

Expert Comment

by:inter
ID: 1360901
Hi,

I have found the problem my friend. A program can only see the icons that it requested from shell. That means if I explicitly request the icon for 'c:\' for example the icon list grows automatically by one. So tell me what kind of icons you want so that we just call SHGetFileinfo for them and our list (Images contains all of that types). For example we may receive:

1 - All drive icons
2 - All common file associations

For example, the image list contains only 5 items for an initial configuration(I remove all shell related components from my test application, for example when you just add TDriveCombo you receive automatically 8 icons. This is due to the component call SHGetFileInfo for drives at design and runtime). Just add this line after creating calling SHGetFileInfo('',...) in the code above and now you have a icon for hard drives:

SHGetFileInfo(PChar('c:\'),0,Info,SizeOf(TShFileInfo),SHGFI_DISPLAYNAME or 0, SFI, SizeOf(SFI), SHGFI_SYSICONINDEX or SHGFI_LARGEICON)

Waiting for your reply,
Igor

0
 
LVL 4

Author Comment

by:jeurk
ID: 1360902
Right cool,
I'd like to have all the logical drive icons like
dsk a:
drive c:
cdrom
removable
ram
audio
network
not connected network
I think I have them all.
If you see one other, don't hesitate to add them.

That things works different between 95 and NT is real shitt.
Oh microsoft.
That guys like you helps me, is real cool.
But that problem should not have been ...
I update the points to 80 for the good work ;)
John
0
 
LVL 5

Expert Comment

by:inter
ID: 1360903
Hi there,

So just after the

SysImList := SHGetFileInfo('', 0, SFI, SizeOf(SFI), SHGFI_SYSICONINDEX or
      SHGFI_LARGEICON);//replace this with SHGFI_SMALLICON for retreving small icons

line in the complete unit code above add the following:(declare i:integer;ch:char;)
...
// receive drives (code I took from the unit you sent)
// DRIVE_REMOVABLE,DRIVE_FIXED,DRIVE_REMOTE,DRIVE_CDROM,
// DRIVE_RAMDISK
  for ch := 'A' to 'Z' do
  begin
   S := ch + ':\';
   i := GetDriveType(PChar(S));
   if i in [0,1] then Continue; // Invalid
   SHGetFileInfo(PChar(S),0,SFI,SizeOf(SFI), SHGFI_DISPLAYNAME or SHGFI_SYSICONINDEX or SHGFI_LARGEICON);
  end;
// And for any other object call for example explorer.exe
   SHGetFileInfo('c:\winnt\explore.exe',0,SFI,SizeOf(SFI), SHGFI_DISPLAYNAME or SHGFI_SYSICONINDEX or SHGFI_LARGEICON);
..

Anyway what kind of application you are writing?
Bye
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360904
I'll try this out.

About the app,
it's called "free space" and shows you how much free space left is on your drives.
If you want a copy, I'll send it to you.
Anyway it's freeware, but my web page is still not up.

John
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360905
It is working my friend.
The solution was there and I could not see it.
Thanks a lot for your help.
Please answer that question so I can graduate it.

0
 
LVL 5

Accepted Solution

by:
inter earned 320 total points
ID: 1360906
Hi,

I am happy that its ok. Thanks,

Sincerely,
Igor
0
 
LVL 4

Author Comment

by:jeurk
ID: 1360907
See You in other theads.
Thanks again.

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

688 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