Subst'ed/removable drive icon reused for new drives
Moderators: white, Hacker, petermad, Stefan2
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
I have much more simple problem which - I suppose - may be connected with the problem described here.
I created a pendrive containing Icon1.ico and Autorun.inf with the following contents:
Tested with Windows 7 64-bit and TC 9.20 Beta 4 64-bit:
1) Open TC
2) Open also "Computer" to see Explorer icons
3) Insert pendrive
4) Explorer shows a new drive icon, which blinks for a moment and then finally displays Icon1.ico
5) TC shows a standard drive icon
6) Restart TC - now it shows Icon1.ico
Regards
I created a pendrive containing Icon1.ico and Autorun.inf with the following contents:
Code: Select all
[autorun]
icon=Icon1.ico
1) Open TC
2) Open also "Computer" to see Explorer icons
3) Insert pendrive
4) Explorer shows a new drive icon, which blinks for a moment and then finally displays Icon1.ico
5) TC shows a standard drive icon
6) Restart TC - now it shows Icon1.ico
Regards
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Unfortunately I couldn't reproduce that on Windows 10. I tried with a USB stick and a USB harddisk, both with their own custom icons.
I will move this to "Will not be changed" for now.
I will move this to "Will not be changed" for now.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Yes, when TC receives WM_DEVICECHANGE with wparam=DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE options.
lparam then points to a DEV_BROADCAST_VOLUME structure. TC reacts when dbcv_devicetype=DBT_DEVTYP_VOLUME.
TC updates the icon immediately, and again with a 2 second delay.
lparam then points to a DEV_BROADCAST_VOLUME structure. TC reacts when dbcv_devicetype=DBT_DEVTYP_VOLUME.
TC updates the icon immediately, and again with a 2 second delay.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
When TC gets the icon immediately within WM_DEVICECHANGE, I ofent get just the default icon. However, some removable decides have autorun.inf defining a different icon. Apparenly Windows notices that only a bit after sending WM_DEVICECHANGE.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
As Christian Ghisler wrote in email, requesting icons using separate .exe program can't be used as a solution because it will cause a slowdown of drive icons appearance, especially on systems with real-time antivirus scanners, so we need different solution.
So it seems that sometimes Windows returns correct icon on 1st Total Commander request, and sometimes on 2nd request (2 seconds after 1st one) after WM_DEVICECHANGE event, and in some cases (mentioned in this topic) it may return correct drive icon on 1st request, but wrong icon second request? And since TC is using an icon it gets from second request, it uses wrong icon? Or Windows may return wrong icons for both requests? Maybe at least for a case with correct icon on first request and wrong one on second request, TC may somehow detect which icon is correct one?
So it seems that sometimes Windows returns correct icon on 1st Total Commander request, and sometimes on 2nd request (2 seconds after 1st one) after WM_DEVICECHANGE event, and in some cases (mentioned in this topic) it may return correct drive icon on 1st request, but wrong icon second request? And since TC is using an icon it gets from second request, it uses wrong icon? Or Windows may return wrong icons for both requests? Maybe at least for a case with correct icon on first request and wrong one on second request, TC may somehow detect which icon is correct one?
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Ukraine's National Bank special bank account:
UA843000010000000047330992708
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
TC uses icons from both first and second request. For example, when a USB stick has its own icon, TC will show standard icon received from first request, and it will change to the specific stick icon after the second request.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Yes, but I meant the case where TC shows correct icon after first request, but wrong icon after second request. Can TC somehow detect it and then show only an icon from first request?ghisler(Author) wrote:TC uses icons from both first and second request. For example, when a USB stick has its own icon, TC will show standard icon received from first request, and it will change to the specific stick icon after the second request.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Ukraine's National Bank special bank account:
UA843000010000000047330992708
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
No, TC just shows what Windows returns. It has no chance to know whether a returned icon is right or wrong.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
According to my tests, for a pendrive with custom icon defined in Autorun.inf, the following messages are received:
- WM_DEVICECHANGE with wParam = DBT_DEVICEARRIVAL is reveived - a standard drive icon is available in the image list,
- then one or more WM_DEVICECHANGE with wParam = DBT_DEVNODES_CHANGED is/are received - a custom (defined in Autorun.inf) drive icon is available in the image list.
This means, that TC should also handle WM_DEVICECHANGE messages with wParam = DBT_DEVNODES_CHANGED - and since DBT_DEVNODES_CHANGED passes no additional info, all removable drive icons should be refreshed on DBT_DEVNODES_CHANGED.
Regards
- WM_DEVICECHANGE with wParam = DBT_DEVICEARRIVAL is reveived - a standard drive icon is available in the image list,
- then one or more WM_DEVICECHANGE with wParam = DBT_DEVNODES_CHANGED is/are received - a custom (defined in Autorun.inf) drive icon is available in the image list.
This means, that TC should also handle WM_DEVICECHANGE messages with wParam = DBT_DEVNODES_CHANGED - and since DBT_DEVNODES_CHANGED passes no additional info, all removable drive icons should be refreshed on DBT_DEVNODES_CHANGED.
Regards
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
But does the icon really change to the correct one? Currently I'm simply re-reading the icons 2 seconds later, and it works fine here.
Could you test with my test tool whether it loads the correct icon when you click on the window?
All you need to do is change the drive letter of the drive to T:
https://totalcommander.ch/win/testiconproblems.zip
Or get the source code here:
https://totalcommander.ch/win/testiconproblems_src.zip
Could you test with my test tool whether it loads the correct icon when you click on the window?
All you need to do is change the drive letter of the drive to T:
https://totalcommander.ch/win/testiconproblems.zip
Or get the source code here:
https://totalcommander.ch/win/testiconproblems_src.zip
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 48125
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
OK, I will add reacting to DBT_DEVNODES_CHANGED in RC2 tomorrow, let's see whether it helps or not.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com