by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 17th January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Extract,Draw and Destroy Icon using ExtractIcon,DrawIcon and DestroyIcon API
API Declarations
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex 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 Declare Function DestroyIcon Lib "user32" (ByVal hicon As Long) As Long
Dim hicon As Long ' Handle to icon
Dim rval As Long ' Return value
Dim index As Long 'Icon index
'Extract and Draw Icon for index=0
index = 0
Form1.Cls ' Clear the form
'Extract Icon from explorer.exe of index=0
hicon = ExtractIcon(App.hInstance, "c:\windows\explorer.exe", index)
rval = DrawIcon(Form1.hdc, 15, 15, hicon) 'draw icon on form
rval = DestroyIcon(hicon) 'Destroy the icon handle
'Extract and Draw Icon for index=0
index = 1
'Extract Icon from explorer.exe of index=1
hicon = ExtractIcon(App.hInstance, "c:\windows\explorer.exe", index)
rval = DrawIcon(Form1.hdc, 50, 15, hicon) 'draw icon on form
rval = DestroyIcon(hicon) 'Destroy the icon handle
End Sub
No comments have been posted about Extract,Draw and Destroy Icon using ExtractIcon,DrawIcon and DestroyIcon API. Why not be the first to post a comment about Extract,Draw and Destroy Icon using ExtractIcon,DrawIcon and DestroyIcon API.