cjwares
Dec 9th, 1999, 02:04 PM
I was just wondering if there is any code (and i'm sure there is) that would call the registry, and return a filetypes icon. If so, i could really use some help. Thanx.
Aaron Young
Dec 10th, 1999, 12:43 AM
If you're after the Icon associated with a File Extension, take a look at the ExtractAssociatedIcon API, eg.
Add a Picturebox, Command Button and CommonDialog Control to a Form..
Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Private Sub Command1_Click()
Dim lIcon As Long
On Error GoTo User_Cancelled
With CommonDialog1
.Flags = cdlOFNNoValidate
.CancelError = True
.DialogTitle = "Select a File.."
.Filter = "All Files (*.*)|*.*"
.ShowOpen
Picture1.Cls
lIcon = ExtractAssociatedIcon(App.hInstance, .FileName, -1)
Call DrawIconEx(Picture1.hdc, 0, 0, lIcon, 32, 32, 0, 0, 3)
End With
User_Cancelled:
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net