Use the ExtractAssociatedIcon() API to get the Icon associated with the specified type of file, ie.
Code:
'Add a Command Button, Picturebox and CommonDialogbox 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 DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Private Sub Command1_Click()
Dim lIcon As Long
On Error GoTo LoadError
With CommonDialog1
.Filter = "All Files|*.*"
.CancelError = True
.ShowOpen
lIcon = ExtractAssociatedIcon(App.hInstance, .FileName, -1)
Caption = lIcon
Picture1.AutoRedraw = True
Call DrawIcon(Picture1.hdc, 0, 0, lIcon)
Picture1 = Picture1.Image
SavePicture Picture1, "C:\Image.bmp"
End With
LoadError:
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]