后面加上 Erase glLargeIcons
        Erase glSmallIcons试试。

解决方案 »

  1.   

    You must destroy all icons extracted by ExtractIconEx by calling the DestroyIcon function.
      

  2.   

    I think it have something to do with safearray.Array in VB is safearry,but the parameter create row array.
      

  3.   

    Use ExtractIcon function instead of ExtractIconEx:
    Following code can run properlyOption Explicit
    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 LongPrivate Declare Function ExtractIconEx Lib "shell32.dll" Alias "ExtractIconExA" (ByVal lpszFile As String, ByVal nIconIndex As Long, phiconLarge As Long, phiconSmall As Long, ByVal nIcons As Long) As Long
    Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As LongPrivate 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 l As Long
    Dim lIcons As Long
    Dim mykey As String
    Dim hIcon As Long, hPrevIcon
    Dim hInst As Long
    hInst = App.hInstance
    Dim sExeName As String
    sExeName = "F:\Brood\starcraft.exe"
    lIcons = ExtractIcon(hInst, sExeName, -1)
    If lIcons <= 0 Then Exit Sub
    Dim ss As Long
    Dim lIndex As IntegerFor lIndex = 0 To lIcons - 1
    hIcon = ExtractIcon(hInst, sExeName, lIndex)
    With PicLarge
        Set .Picture = LoadPicture("")
        .AutoRedraw = False
        Call DrawIcon(PicLarge.hdc, 0, 0, hIcon)
        DestroyIcon hIcon    
    End With
    Next lIndex
    End Sub