Dedicated Icon for USB drive ?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
bberger
Junior Member
Junior Member
Posts: 4
Joined: 2005-10-21, 07:33 UTC
Location: Neuchâtel, Suisse

Dedicated Icon for USB drive ?

Post by *bberger »

Hi,
Could you tell me if there is a way to have a distinct Icon for a USB drives (like there is a distinct one for USB keys)?

I have search in this forum, and while people mention that it is possible (Jgn on the 29th dec 06):
> ... TC shows distinct icons for diskette, hardisk, networkdrives, cd-dvd, usb and other external disks...

I haven't found out how to do it.

Thanks in advance for your support.
Bernard
"Insanity: doing the same thing over and over again and expecting different results". - Albert Einstein
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50843
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, unfortunately this isn't possible. Without admin rights, there is no way to find out whether a drive is connected via USB or internally. This is only possible for USB sticks, but only when they are formatted as a super floppy, not as a harddisk (with partition table).
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
Did you try or are you already using SetupDiGetDeviceRegistryProperty with SPDRP_REMOVAL_POLICY? Microsoft recommends this functions to find out if a drive is a usb drive.

Documentation
http://msdn2.microsoft.com/en-us/library/ms792967.aspx
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50843
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Well, yes, but it requires admin rights to call the functions to get the structures needed:

SetupDiCreateDeviceInfo
http://msdn2.microsoft.com/en-us/library/ms792966.aspx

>>The caller of this function must be a member of the Administrators group.<<
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
I'm sorry. I must have overseen this limitation :oops:
bberger
Junior Member
Junior Member
Posts: 4
Joined: 2005-10-21, 07:33 UTC
Location: Neuchâtel, Suisse

Post by *bberger »

Many thanks for your quick answer Christian.

Keep-up the good work and have a nice week-end (almost time...)

Bernard
"Insanity: doing the same thing over and over again and expecting different results". - Albert Einstein
User avatar
DarkRuleR
Member
Member
Posts: 190
Joined: 2003-02-20, 22:23 UTC
Location: Netherlands

Post by *DarkRuleR »

Hi,

There is an possibility to define your own icon file per drive.
Windows Explorer and SpeedCommander are using it.

When you create a "autorun.inf" file in the root of your removable drive and define the ICON variable.
Example:

[autorun]
ICON=AUTORUN\NAME.ICO

You can define your own icon.

This looks like this:
(Look for the Western Digital icon from my Passport I: drive)

Windows Explorer:
http://img103.imageshack.us/my.php?image=windowsexplorerrm0.jpg

SpeedCommander:
http://img103.imageshack.us/my.php?image=speedcommanderyj0.jpg

It would be even more great if this applies for non removable drives also.

DR...
#106383 Windows 10 Pro 64-bit
User avatar
menet
Member
Member
Posts: 199
Joined: 2005-04-21, 12:27 UTC
Location: Paris, France

Post by *menet »

Hi,

I have tried the DarkRuleR solution, it works well with Windows Explorer :P

But it has no effect with Total Commander :(

Christian, is it possible to include that in a next TC version ?

Bes regards :wink:
#22273 Personal licence
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50843
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is that the button control which I'm currently using is only accepting bitmaps as the images, not icons.
Author of Total Commander
https://www.ghisler.com
User avatar
D1P
Senior Member
Senior Member
Posts: 233
Joined: 2005-02-28, 18:29 UTC
Location: Moscow
Contact:

Post by *D1P »

The problem is that the button control which I'm currently using is only accepting bitmaps as the images, not icons.
Fast icon to bitmap converting can be implemented very easy, or i miss something?

Code: Select all

Var
Icon   : TIcon;
Bitmap : TBitmap;
begin
Icon   := TIcon.Create;
Bitmap := TBitmap.Create;
Icon.LoadFromFile('c:\picture.ico');
Bitmap.Width := Icon.Width;
Bitmap.Height := Icon.Height;
Bitmap.Canvas.Draw(0, 0, Icon);
Icon.Free;
{use bitmap code}
Bitmap.Free;
end;
User avatar
DarkRuleR
Member
Member
Posts: 190
Joined: 2003-02-20, 22:23 UTC
Location: Netherlands

Post by *DarkRuleR »

ghisler(Author) wrote:The problem is that the button control which I'm currently using is only accepting bitmaps as the images, not icons.
2ghisler(Author)
What do you think about the solution D1P suggested?

Or maybe using a proprietary solution.
For example:

TC scans for the file tcdriveicon.bmp in the root of every drive and if the file exists use it as drive icon.

DR...
#106383 Windows 10 Pro 64-bit
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

What do you think about the solution D1P suggested?
This is embarrassing. Do you think the author doesn't know how to convert an icon into a bitmap?

The best solution would be to reuse the button bar control for the drive bars.
User avatar
DarkRuleR
Member
Member
Posts: 190
Joined: 2003-02-20, 22:23 UTC
Location: Netherlands

Post by *DarkRuleR »

Lefteous wrote:
What do you think about the solution D1P suggested?
This is embarrassing. Do you think the author doesn't know how to convert an icon into a bitmap?

The best solution would be to reuse the button bar control for the drive bars.
Hi Lefteous,

Don't feel embarrased.
I'm certainly not feeling embarresed.

The way the author replies leaves space for discussion.

I personally still have questions like.
"is this suggestion still in the process of looking into?".
"or is it to much work to program?".
etc. etc.

To make a thing clear I don't think the author needs program lessens.
I made the remark as an request for more information.

Greetz,

DR...
#106383 Windows 10 Pro 64-bit
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50843
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is with the new half-transparent icons. They can't be converted to a bitmap. The delphi buttons use a bitmap where the top-left pixel gives the transparency color, so there is just either transparent or color, no half-transparence. That's one of the reasons why I had to completely rewrite the button bar code to support XP themes. I'm now using icons instead of bitmaps for the icons. But that's a self-written control, not like the drive buttons...
Author of Total Commander
https://www.ghisler.com
Post Reply