You should use the ExtractAssociatedIcon Win32 API function:
By the way, this function is incorrectly declared in the API viewerCode:Option Explicit 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 cmdSetIcon_Click() Dim hIcon As Long ' Extract icon from Notepad.exe hIcon = ExtractAssociatedIcon(0, "Notepad.exe", 0) If hIcon = 0 Then Exit Sub ' Draw it in the PictureBox, picIcon Call DrawIcon(picIcon.hDC, 0, 0, hIcon) End Sub VBBrowser v2.2.1![]()




Reply With Quote