INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

vb.net translation (ishellitem)

vb.net translation (ishellitem)

(OP)
The following vb.net code block serves to retrieve Windows thumbnails. I like some opinions as to whether it will translate to VBA or whether a better route will be to amend to a vb.net class and create a .dll ?

Thanks much.

[code ] Public Enum SIIGBF
'SIIGBF_RESIZETOFIT = 0
SIIGBF_BIGGERSIZEOK = 1
'SIIGBF_MEMORYONLY = 2
'SIIGBF_ICONONLY = 4
SIIGBF_THUMBNAILONLY = 8
SIIGBF_INCACHEONLY = 16
End Enum

Public Enum SIGDN As UInteger
NORMALDISPLAY = 0
PARENTRELATIVEPARSING = &H80018001UI
PARENTRELATIVEFORADDRESSBAR = &H8001C001UI
DESKTOPABSOLUTEPARSING = &H80028000UI
PARENTRELATIVEEDITING = &H80031001UI
DESKTOPABSOLUTEEDITING = &H8004C000UI
FILESYSPATH = &H80058000UI
URL = &H80068000UI
End Enum

_
Private Interface IShellItemImageFactory
Sub GetImage(ByVal size As IMAGESIZE, ByVal flags As SIIGBF, ByRef phbm As IntPtr)
End Interface

_
Private Interface IShellItem
Sub BindToHandler(ByVal pbc As IntPtr, ByVal bhid As Guid, _
ByVal riid As Guid, ByRef ppv As IntPtr)
Sub GetParent(ByRef ppsi As IShellItem)
Sub GetDisplayName(ByVal sigdnName As SIGDN, ByRef ppszName As IntPtr)
Sub GetAttributes(ByVal sfgaoMask As UInt32, ByRef psfgaoAttribs As UInt32)
Sub Compare(ByVal psi As IShellItem, ByVal hint As UInt32, ByRef piOrder As Integer)
End Interface

_
Private Sub SHCreateItemFromParsingName( ByVal pszPath As String, ByVal pbc As IntPtr, _
ByVal riid As Guid, IidParameterIndex:=2)> ByRef ppv As IShellItem)
End Sub
'Declare Sub SHCreateItemFromParsingName Lib "shell32.dll" ( ByVal pszPath As String, _
' ByVal pbc As IntPtr, _
' ByVal riid As Guid, ByRef ppv As IShellItem)

_
Public Structure IMAGESIZE
Public cx As Integer
Public cy As Integer
Public Sub New(ByVal cx As Integer, ByVal cy As Integer)
Me.cx = cx
Me.cy = cy
End Sub
End Structure


Public Function GetShellIcon(ByVal ImagePath As String, Optional ByVal ThumbWidth As Integer = 100, _
Optional ByVal ThumbHeight As Integer = 100) As Image

Dim mySIIGBF As SIIGBF
Dim ppsi As IShellItem = Nothing
Dim hbitmap As IntPtr = IntPtr.Zero
Dim uuid As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
Dim bmp As Image 'bitmap

SHCreateItemFromParsingName(ImagePath, IntPtr.Zero, uuid, ppsi)
DirectCast(ppsi, IShellItemImageFactory).GetImage(New IMAGESIZE(ThumbWidth, ThumbHeight), mySIIGBF, hbitmap)
bmp = System.Drawing.Image.FromHbitmap(hbitmap)
Return bmp
hbitmap = IntPtr.Zero
End Function[/code]

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close