Fred wrote:Any chances ?
It still does not work here on my system. OpenFileRequester() with PB 32bit does not show
.EXE icons too, so it looks like an issue with my system only, not directly a PureBasic bug.
Tested code on Win 7 64bit Ultimate, using PureBasic 4.61 x86:
Code: Select all
;
; http://www.purebasic.fr/english/viewtopic.php?f=4&t=48559
;
CoInitialize_(0) ; required for SHGetFileInfo_()
;InitCommonControlsEx_()
;FileIconInit_(0)
lib = LoadLibrary_("shell32.dll")
If lib
address = GetProcAddress_(lib,660)
If address
Debug "Calling FileIconInit"
CallFunctionFast(address,1)
EndIf
EndIf
If OpenWindow(0,0,0,450,500,"ExplorerListGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ExplorerListGadget(0, 0, 0, 450, 500, "C:\*.exe;*.dll;*.ico");,#PB_Explorer_FullRowSelect)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Procedure ShowIcon(hIcon)
OpenWindow(0,0,0,200,200,"Icon",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(0,0,0,200,200,hIcon)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndProcedure
Procedure Info( Filename.s )
shFileInfo.SHFILEINFO
Debug Filename
Debug SHGetFileInfo_(@Filename, 0, @shFileInfo, SizeOf(SHFILEINFO), #SHGFI_TYPENAME | #SHGFI_SYSICONINDEX | #SHGFI_SMALLICON );| #SHGFI_ICON)
Debug shFileInfo\iIcon
Debug shFileInfo\hIcon
Debug PeekS(@shFileInfo\szTypeName[0])
EndProcedure
Procedure Info2( Filename.s )
shFileInfo.SHFILEINFO
Debug Filename
Debug SHGetFileInfo_(@Filename, 0, @shFileInfo, SizeOf(SHFILEINFO), #SHGFI_TYPENAME | #SHGFI_SYSICONINDEX | #SHGFI_SMALLICON | #SHGFI_DISPLAYNAME )
Debug shFileInfo\iIcon
Debug shFileInfo\hIcon
Debug PeekS(@shFileInfo\szTypeName[0])
Debug PeekS(@shFileInfo\szDisplayName[0])
If GetExtensionPart(Filename)="exe"
;
; extract icon
;
shFileInfo\hIcon = ExtractIcon_(0,@Filename,0)
If shFileInfo\hIcon > 1
ShowIcon(shFileInfo\hIcon)
DestroyIcon_(shFileInfo\hIcon)
EndIf
;
; extract big icon
;
If ExtractIconEx_(@Filename,0,@shFileInfo\hIcon,0,1)
ShowIcon(shFileInfo\hIcon)
DestroyIcon_(shFileInfo\hIcon)
EndIf
;
; extract small icon
;
If ExtractIconEx_(@Filename,0,0,@shFileInfo\hIcon,1)
ShowIcon(shFileInfo\hIcon)
DestroyIcon_(shFileInfo\hIcon)
EndIf
EndIf
hIcon = ExtractAssociatedIcon_(0,@FileName,@w.w)
If hIcon
ShowIcon(hIcon)
DestroyIcon_(hIcon)
EndIf
EndProcedure
Info( "c:\Windows\calc.exe" )
Debug "-----------------"
Info( "c:\Windows\advapi32.dll" )
Debug "-----------------"
Info2( "c:\Windows\calc.exe" )
Debug "-----------------"
Info2( "c:\Windows\advapi32.dll" )
CoUninitialize_()
My Debugger output:
Code: Select all
Calling FileIconInit
c:\Windows\calc.exe
5927960
0
0
Application
-----------------
c:\Windows\advapi32.dll
5927960
179
0
Application extension
-----------------
c:\Windows\calc.exe
5927960
0
0
Application
calc
-----------------
c:\Windows\advapi32.dll
5927960
179
0
Application extension
advapi32.dll
So the only 'workaround' would be to use ExtractIcon_(), ExtractIconEx_() (with small and big icons)
and maybe ExtractAssociatedIcon_() to get the real .EXE icon.
If this functions do not return a icon (the .EXE does not have an internal icon), use the System Image List icon returned by SHGetFileInfo_().
Looks like I am the only one having this issue, so I wouldn't call it an important bug. I am running this system
for a long time (when Win7 came out) and installed quite a lot of big commercial applications over that time,
so it could be a system issue just here on my system.