Just starting out? Need help? Post your questions and find answers here.
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Sun Oct 16, 2005 7:14 pm
Hi !
I've got something I would like to do : In Explorer, we can get specific file type, like :
How can I get this type in Purebasic ?
Thanks !
Gaetan
freak
PureBasic Team
Posts: 5940 Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany
Post
by freak » Sun Oct 16, 2005 7:56 pm
Code: Select all
File$ = OpenFileRequester("Choose File...", "", "All Files (*.*)|*.*", 0)
If File$ <> ""
If SHGetFileInfo_(@File$, 0, @info.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_TYPENAME)
Debug PeekS(@info\szTypeName[0], 80)
EndIf
EndIf
quidquid Latine dictum sit altum videtur
roachofdeath
User
Posts: 78 Joined: Sun Apr 24, 2005 3:22 am
Post
by roachofdeath » Sun Oct 16, 2005 8:02 pm
Doh, you beat me to it freak
If you want to do it the long way, find the extention in the registry, and get the (Default) value of it. Then search for the default value in the registry, and there will be the file type.
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Sun Oct 16, 2005 8:07 pm
freak wrote: Code: Select all
File$ = OpenFileRequester("Choose File...", "", "All Files (*.*)|*.*", 0)
If File$ <> ""
If SHGetFileInfo_(@File$, 0, @info.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_TYPENAME)
Debug PeekS(@info\szTypeName[0], 80)
EndIf
EndIf
Perfect and fast answer, I love you
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Sun Oct 16, 2005 8:10 pm
Maybe do you know also where to get the icon associated to the type ? That would help me a lot too
freak
PureBasic Team
Posts: 5940 Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany
Post
by freak » Sun Oct 16, 2005 8:21 pm
It can all be done with this function. Just see the possible flags options here:
http://msdn.microsoft.com/library/defau ... leinfo.asp
for the icon:
Code: Select all
File$ = OpenFileRequester("Choose File...", "", "All Files (*.*)|*.*", 0)
If File$ <> ""
If SHGetFileInfo_(@File$, 0, @info.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_ICON|#SHGFI_LARGEICON)
; Icon handle is returned here:
Debug info\hIcon
; if you want a PB image:
CreateImage(1, 32, 32)
If StartDrawing(ImageOutput())
DrawImage(info\hIcon, 0, 0)
EndIf
; free icon when no longer needed:
DestroyIcon_(info\hIcon)
EndIf
EndIf
There is also a flag to get the small icon...
quidquid Latine dictum sit altum videtur
Polo
Addict
Posts: 2422 Joined: Tue May 06, 2003 5:07 pm
Location: UK
Post
by Polo » Sun Oct 16, 2005 8:48 pm
Thanks again, it works really well !!