Code: Select all
StartDrawing(IExtractIconEx_(file,0,large(),small(),1)
DrawIconEx_(image_h,x,y,large(0),w,w,0,0,#DI_NORMAL)
DestroyIcon_(small(0))
DestroyIcon_(large(0))
Code: Select all
StartDrawing(IExtractIconEx_(file,0,large(),small(),1)
DrawIconEx_(image_h,x,y,large(0),w,w,0,0,#DI_NORMAL)
DestroyIcon_(small(0))
DestroyIcon_(large(0))
Code: Select all
OpenWindow(1,100,100,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ImageGadget(2,10,10,180,180,0)
CreateImage(3,180,180)
;
Dim large(10)
Dim small(10)
file.s = "notepad.exe"
file.s = "C:\googledrive\icons\flat\command_prompt_1.ico"
file.s = "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Google Profile.ico"
;
h=StartDrawing(ImageOutput(3))
Box(0,0,180,180,$00FFFF)
n = ExtractIconEx_(file,-1,0,0,0)
Debug n
ExtractIconEx_(file,0,large(),small(),1)
DrawIconEx_(h,x,y,large(0),180,180,0,0,#DI_NORMAL)
DestroyIcon_(small(0))
DestroyIcon_(large(0))
StopDrawing()
SetGadgetState(2,ImageID(3))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
OpenWindow(1,100,100,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ImageGadget(2,10,10,180,180,0)
CreateImage(3,180,180)
;
Dim large(10)
Dim small(10)
file.s = "notepad.exe"
;file.s = "C:\googledrive\icons\flat\command_prompt_1.ico"
;file.s = "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Google Profile.ico"
;
h=StartDrawing(ImageOutput(3))
Box(0,0,180,180,$00FFFF)
Define hicon
SHExtractIcons_(file, 0, 128, 128, @hicon, 0, 1, 0)
DrawIconEx_(h,x,y, hicon,180,180,0,0,#DI_NORMAL)
DestroyIcon_(small(0))
DestroyIcon_(large(0))
StopDrawing()
SetGadgetState(2,ImageID(3))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Which version of PureBasic are you running? 5.73LTS nor Alpha4 seem to recognize that Windows API function.
SHExtractIconsW is not exported by name or declared in a public header file.
To use it, you must declare a matching prototype and use GetProcAddress to request
a function pointer from Shell32.dll that can be used to call this function.
Code: Select all
OpenWindow(1,100,100,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ImageGadget(2,10,10,180,180,0)
CreateImage(3,180,180)
;
OpenLibrary(4,"shell32.dll")
p_shextracticonsw = GetFunction(4,"SHExtractIconsW")
;
hicon.i = 0
;
file.s = "notepad.exe"
;file.s = "C:\googledrive\icons\flat\command_prompt_1.ico"
;file.s = "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Google Profile.ico"
;
h=StartDrawing(ImageOutput(3))
Box(0,0,180,180,$00FFFF)
CallFunctionFast(p_shextracticonsw,@file,0,128,128,@hicon,0,1,0)
DrawIconEx_(h,x,y,hicon,180,180,0,0,#DI_NORMAL)
DestroyIcon_(hicon)
StopDrawing()
SetGadgetState(2,ImageID(3))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
;
CloseLibrary(4)
Code: Select all
Prototype pPrivateExtractIcons(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
OpenLibrary(0, "user32.dll")
PrivateExtractIcons.pPrivateExtractIcons = GetFunction(0, "PrivateExtractIconsW")
CloseLibrary(0)
OpenWindow(1,100,100,200,200,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ImageGadget(2,10,10,180,180,0)
CreateImage(3,180,180)
;
Dim large(10)
Dim small(10)
file.s = "notepad.exe"
;file.s = "C:\googledrive\icons\flat\command_prompt_1.ico"
;file.s = "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Google Profile.ico"
;
h=StartDrawing(ImageOutput(3))
Box(0,0,180,180,$00FFFF)
Define hicon
;SHExtractIcons_(file, 0, 128, 128, @hicon, 0, 1, 0)
PrivateExtractIcons(@file, 0, 128, 128, @hicon, 0, 1, 0)
DrawIconEx_(h,x,y, hicon,180,180,0,0,#DI_NORMAL)
DestroyIcon_(small(0))
DestroyIcon_(large(0))
StopDrawing()
SetGadgetState(2,ImageID(3))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow