Results 1 to 11 of 11

Thread: IExtractImage

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    IExtractImage

    Hi, I have this function to get the thumbnails of files and folders, and it works fine, but in windows 7, it does not work with folders, the function uses "IExtractImage", in window 7 the error is when you call GetUIObjectOf (-2144927486)
    Also try to use IShellItemImageFactory but this did not even work on windows 10

    Name:  Sin título.png
Views: 1578
Size:  20.8 KB

    The strangest thing is that in a moment he walked but when he reset the project stopped working.

    ----------EDIT-----------------------------------------
    For some strange reason when compiling the project, the IDE starts working, some library is loaded in memory that makes it work but what will be the library?

    ----------------------------------------------------------
    vb Code:
    1. Public Function GetThumbnailImage(ByVal fileName As String, ByVal lWidth As Long, ByVal lHeight As Long) As Long
    2.  
    3.     Dim DesktopFolder As IShellFolder
    4.     Dim SomeFolder As IShellFolder
    5.     Dim ExtractImage As IExtractImage
    6.     Dim Pidl As Long
    7.     Dim FilePidl As Long
    8.     Dim IID_IShellFolder As UUID
    9.     Dim IID_IExtractImage As UUID
    10.     Dim ThePath As String
    11.     Dim tSize As SIZE
    12.     Dim FolderName  As String
    13.     Dim ShortFileName As String
    14.  
    15.     CLSIDFromString StrPtr("{000214E6-0000-0000-C000-000000000046}"), IID_IShellFolder
    16.     CLSIDFromString StrPtr("{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}"), IID_IExtractImage
    17.    
    18.  
    19.  
    20.     FolderName = Left$(fileName, InStrRev(fileName, "\") - 1)
    21.     ShortFileName = Mid$(fileName, InStrRev(fileName, "\") + 1)
    22.  
    23.     SHGetDesktopFolder DesktopFolder
    24.    
    25.     Call DesktopFolder.ParseDisplayName(0&, 0&, StrPtr(FolderName), 0, Pidl, 0)
    26.     Call DesktopFolder.BindToObject(Pidl, 0&, IID_IShellFolder, SomeFolder)
    27.  
    28.     Call SomeFolder.ParseDisplayName(0&, 0&, StrPtr(ShortFileName), 0, FilePidl, 0)
    29.     Call SomeFolder.GetUIObjectOf(0&, 1, FilePidl, IID_IExtractImage, 0&, ExtractImage)
    30.  
    31.  
    32.     ThePath = String$(MAX_PATH, 0)
    33.    
    34.     tSize.cx = lWidth
    35.     tSize.cy = lHeight
    36.    
    37.     ExtractImage.GetLocation StrPtr(ThePath), MAX_PATH, 0&, tSize, 32, IEIFLAG_NOBORDER Or IEIFLAG_SCREEN Or IEIFLAG_OFFLINE
    38.            
    39.     GetThumbnailImage = ExtractImage.extract
    40.    
    41.  
    42.     'Dim ISIIF As IShellItemImageFactory
    43.     'Dim IID_IShellItemImageFactory As UUID
    44.     'Dim hr As Long
    45.     'Dim hBmp As Long
    46.    
    47.     'CLSIDFromString StrPtr("{BCC18B79-BA16-442F-80C4-8A59C30C463B}"), IID_IShellItemImageFactory
    48.     'hr = SHCreateItemFromIDList(FilePidl, IID_IShellItemImageFactory, ISIIF)
    49.     'hr = ISIIF.GetImage(tSize.cx, tSize.cy, SIIGBF_THUMBNAILONLY, hBmp)
    50.        
    51.     'GetThumbnailImage = hBmp
    52.  
    53.     CoTaskMemFree (Pidl)
    54.     CoTaskMemFree (FilePidl)
    55.  
    56. End Function

    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim hBmp As Long
    3.     Dim hImgList As Long
    4.    
    5.     hBmp = GetThumbnailImage(Environ("userprofile"), 120, 120)
    6.     hImgList = ImageList_Create(120, 120, ILC_COLOR32 Or ILC_MASK, 0, 0)
    7.     Call ImageList_Add(hImgList, hBmp, 0)
    8.     ImageList_Draw hImgList, 0, Me.hdc, 0, 0, ILD_TRANSPARENT
    9.    
    10.     DeleteObject hBmp
    11. End Sub

    I clarify, my intention is to obtain the thumbnails, not the icon
    Last edited by LeandroA; Jan 29th, 2017 at 10:45 PM.
    leandroascierto.com Visual Basic 6 projects

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width