
<System.Runtime.InteropServices.DllImport("shell32.dll")> _
Private Shared Function SHGetFileInfo(ByVal pszPath As String, ByVal dwFileAttributes As UInt32, ByRef structPtr As IntPtr, ByVal cbFileInfo As UInt32, ByVal uFlagsn As UInt32) As Int32
End Function
Public Shared Function ExtractIcon(ByVal path As String, ByVal large As Boolean) As Icon
Dim hwnd As IntPtr = IntPtr.Zero
Dim flags As UInt32 = &H100 Or &H10 Or CUInt(If(large, &H0, &H1))
SHGetFileInfo(path, 256, hwnd, 0, flags)
If hwnd <> IntPtr.Zero Then
Return Icon.FromHandle(hwnd)
Else
Return Nothing
End If
End Function
Me.PictureBox1.Image = ExtractIcon("C:\example.exe", true).ToBitmap()
Private Sub btnGame1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGame1.Click
If ofdSelectGame1.FileName = "" Then
ofdSelectGame1.ShowDialog()
Dim ico As Icon = Icon.ExtractAssociatedIcon(ofdSelectGame1.FileName)
btnGame1.Image = ico.ToBitmap()
Else
Shell(ofdSelectGame1.FileName)
End If
End Sub
.