Click here to Skip to main content
15,890,399 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How to identify Event handling in TFS 2012 for Bug work item onlt Pin
jkirkerx28-Jun-12 11:50
professionaljkirkerx28-Jun-12 11:50 
Questionasp. net deployment Pin
sc steinhayse27-Jun-12 19:13
sc steinhayse27-Jun-12 19:13 
AnswerRe: asp. net deployment Pin
Vani Kulkarni28-Jun-12 0:56
professionalVani Kulkarni28-Jun-12 0:56 
QuestionStoring file in a Stream rather than storing in the file Pin
indian14327-Jun-12 11:04
indian14327-Jun-12 11:04 
AnswerRe: Storing file in a Stream rather than storing in the file Pin
R. Giskard Reventlov27-Jun-12 11:28
R. Giskard Reventlov27-Jun-12 11:28 
GeneralRe: Storing file in a Stream rather than storing in the file Pin
indian14327-Jun-12 12:02
indian14327-Jun-12 12:02 
GeneralRe: Storing file in a Stream rather than storing in the file Pin
indian14327-Jun-12 14:14
indian14327-Jun-12 14:14 
GeneralRe: Storing file in a Stream rather than storing in the file Pin
jkirkerx27-Jun-12 15:35
professionaljkirkerx27-Jun-12 15:35 
I'm not holding back information on you.

I did some research, and it seems that Microsoft Sharepoint, the website code that allows folks to share documents, has capabilities that allows the indexing of a folder full of office documents, to be listed like items in a store, complete with thumbnails, and so forth.

A little bit more research lead me to shell32.dll XP SP 2 and beyond, was modified to generate thumbnails of office documents.

I don't know how large your image needs to be, but shell32 should be able to provide at least 18 dpi or resolution.

Fax technology is interesting, it can convert any document as a printer to a TIFF I think at 200 dpi, or more. I haven't done any research on it yet. Just a thought.

This is as far as I have got with shell32, I'm still working in the IShellFolder interface. Most of the working examples are in c#, and I need vb so I don't have to create a new dll for it. So its managed code running c++. I pieced it together, and wrote part of it by hand.

Will take it for a test run soon, to watch it bomb, and make corrections.


Imports System
Imports System.Text
Imports System.Drawing
Imports System.Drawing.Imaging.BitmapData
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Web.UI.WebControls.Image

Public Class getThumbnails

    Const MAX_PATH As Integer = 260

    Public Enum IEIFLAG As Integer
        ASYNC = &H1
        CACHE = &H2
        ASPECT = &H4
        OFFLINE = &H8
        GLEAM = &H10
        SCREEN = &H20
        ORIGSIZE = &H40
        NOSTAMP = &H80
        NOBORDER = &H100
        QUALITY = &H200
    End Enum
    <StructLayout(LayoutKind.Sequential)> _
    Public Structure STRRET_CSTR
        Public uType As Integer
        <FieldOffset(4), MarshalAs(UnmanagedType.LPWStr)> _
        Public pOleStr As String
        <FieldOffset(4)> _
        Public uOffset As Integer
        <FieldOffset(4), MarshalAs(UnmanagedType.ByValArray, SizeConst:=520)> _
        Public strName As Byte()
    End Structure
    <StructLayout(LayoutKind.Sequential)> _
    Public Structure SIZE
        Public cx As Integer
        Public cy As Integer
    End Structure
    <ComImportAttribute(), _
     GuidAttribute("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1"), _
     InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
    Public Interface IExtractImage

        Sub GetLocation( _
            ByVal pszPathBuffer As IntPtr, _
            ByVal cch As Integer, _
            ByRef pdwPriority As Integer, _
            ByRef prgSize As SIZE, _
            ByVal dwRecClrDepth As Integer, _
            ByRef pdwFlags As Integer)

        Sub Extract(ByRef phBmpThumbnail As IntPtr)

    End Interface
    Public Shared Function GetThumbnailImage( _
        ByVal fileName As String, _
        ByVal longestEdge As Integer,
        ByVal colorDepth As Integer) As Image

        Dim desktopFolder As IShellFolder = Nothing
        Dim someFolder As IShellFolder = Nothing
        Dim extract As IExtractImage = Nothing
        Dim pidl As IntPtr
        Dim filePidl As IntPtr

        'Manually define the IIDs for IShellFolder and IExtractImage
        Dim IID_IShellFolder = New Guid("000214E6-0000-0000-C000-000000000046")
        Dim IID_IExtractImage = New Guid("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1")

        'Divide the file name into a path and file name
        Dim folderName = Path.GetDirectoryName(fileName)
        Dim shortFileName = Path.GetFileName(fileName)

        'Get the desktop IShellFolder
        IShellFolder.ShellInterop.SHGetDesktopFolder(desktopFolder)

        'Get the parent folder IShellFolder
        desktopFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, folderName, 0, pidl, 0)
        desktopFolder.BindToObject(pidl, IntPtr.Zero, IID_IShellFolder, someFolder)

        'Get the file's IExtractImage
        someFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, shortFileName, 0, filePidl, 0)
        someFolder.GetUIObjectOf(IntPtr.Zero, 1, filePidl, IID_IExtractImage, 0, extract)

        'Set the size
        Dim size As SIZE
        size.cx = 500
        size.cy = 500

        Dim flags = IEIFLAG.ORIGSIZE Or IEIFLAG.QUALITY
        Dim bmp As IntPtr
        Dim thePath = Marshal.AllocHGlobal(MAX_PATH)

        'Interop will throw an exception if one of these calls fail.
        Try
            extract.GetLocation(thePath, MAX_PATH, 0, size, colorDepth, flags)
            extract.Extract(bmp)
        Catch ex As Exception
        End Try

        'Free the global memory we allocated for the path string
        Marshal.FreeHGlobal(thePath)

        'Free the pidls. The Runtime Callable Wrappers 
        'should automatically release the COM objects
        Marshal.FreeCoTaskMem(pidl)
        Marshal.FreeCoTaskMem(filePidl)

        If Not bmp.Equals(IntPtr.Zero) Then
            GetThumbnailImage = Image.FromHbitmap(bmp)
        Else
            GetThumbnailImage = Nothing
        End If
    End Function

End Class


Imports System
Imports System.Runtime.InteropServices

<ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
    Guid("000214E6-0000-0000-C000-000000000046")> _
Interface IShellFolder

    <Flags()> _
    Enum SHCONTF
        CHECKING_FOR_CHILDREN = &H10    '  Windows 7 and later.
        FOLDERS = &H20                  '  Include items that are folders in the enumeration.
        NONFOLDERS = &H40               '  Include items that are not folders in the enumeration.
        INCLUDEHIDDEN = &H80            '  Include hidden items in the enumeration  
        INIT_ON_FIRST_NEXT = &H100      '  . No longer used; always assumed  
        NETPRINTERSRCH = &H200          '  . The calling application is looking for printer objects.
        SHAREABLE = &H400               '  . The calling application is looking for resources that can be shared.
        STORAGE = &H800                 '  . Include items with accessible storage and their ancestors, including hidden items.
        NAVIGATION_ENUM = &H1000        '  . Windows 7 and later   '  . Child folders should provide a navigation enumeration.
        FASTITEMS = &H2000              '  . Windows Vista and later   '  . The calling application is looking for resources that can be enumerated quickly.
        FLATLIST = &H4000               '  . Windows Vista and later   '  . Enumerate items as a simple list even if the folder itself is not structured in that way.
        ENABLE_ASYNC = &H8000           '  . Windows Vista and later   '  . The calling application is monitoring for change notifications   '  . This means that the enumerator does not have to return all results   '  . Items can be reported through change notifications.
        INCLUDESUPERHIDDEN = &H10000    '  . Windows 7 and later   '  . Include hidden system items in the enumeration  

    End Enum
    <Flags()> _
    Enum E_STRRET : int
        WSTR = &H0          ' Use STRRET.pOleStr
        OFFSET = &H1        ' Use STRRET.uOffset to Ansi
        C_STR = &H2         ' Use STRRET.cStr
    End Enum
    <PreserveSig()> _
    Function ParseDisplayName(ByVal hwnd As IntPtr,
        ByVal pbc As IntPtr, <MarshalAs(UnmanagedType.LPWStr)>
        ByVal pszDisplayName As String, ByRef pchEaten As Integer,
        ByRef ppidl As IntPtr,
        ByRef pdwAttributes As Integer) As Integer

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function EnumObjects(ByVal hwnd As IntPtr,
        ByVal grfFlags As SHCONTF,
        ByRef ppenumIDList As IntPtr) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function BindToObject(ByVal pidl As IntPtr,
        ByVal pbc As IntPtr,
        ByRef riid As Guid,
        ByRef ppv As IntPtr) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function BindToStorage(ByVal pidl As IntPtr,
        ByVal pbc As IntPtr,
        ByRef riid As Guid,
        ByRef ppv As IntPtr) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function CompareIDs(ByVal lParam As Int32,
        ByVal pidl1 As IntPtr,
        ByVal pidl2 As IntPtr) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function CreateViewObject(ByVal hwndOwner As IntPtr,
        ByVal riid As Guid,
        ByRef ppv As IntPtr) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function GetAttributesOf(ByVal cidl As Integer,
        ByRef apidl As IntPtr,
        ByRef rgfInOut As Integer) As Integer

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function GetUIObjectOf(ByVal hwndOwner As IntPtr,
        ByVal cidl As UInt32,
        ByVal apidl() As IntPtr,
        ByVal riid As Guid,
        ByRef rgfReserved As UInt32,
        ByRef ppv As IntPtr) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function GetDisplayNameOf(ByVal pidl As IntPtr,
        ByVal uFlags As Integer,
        ByRef pName As E_STRRET) As Int32

    '//////////////////////////////////////////////////////////////////////////////////////////////

    <PreserveSig()> _
    Function SetNameOf(ByVal hwnd As IntPtr,
        ByVal pidl As IntPtr,
        <MarshalAs(UnmanagedType.LPWStr)> ByVal pszName As [String],
        ByVal uFlags As UInt32,
        ByRef ppidlOut As IntPtr) As Int32

    '///////////////////////////////////////////////////////////////////////////////////////////////

    Sub BindToObject(pidl As IntPtr, Zero As IntPtr, IID_IShellFolder As Object, someFolder As IShellFolder)
    Sub GetUIObjectOf(Zero As IntPtr, p2 As Integer, filePidl As IntPtr, IID_IExtractImage As Object, p5 As Integer, extract As getThumbnails.IExtractImage)

    Class ShellInterop
        <DllImport("shell32.dll", CharSet:=CharSet.Auto)> _
        Public Shared Function SHGetDesktopFolder( _
          <Out()> ByRef ppshf As IShellFolder) As Integer
        End Function
    End Class

End Interface

GeneralRe: Storing file in a Stream rather than storing in the file Pin
indian14328-Jun-12 5:29
indian14328-Jun-12 5:29 
GeneralRe: Storing file in a Stream rather than storing in the file Pin
jkirkerx28-Jun-12 7:12
professionaljkirkerx28-Jun-12 7:12 
GeneralRe: Storing file in a Stream rather than storing in the file Pin
indian14328-Jun-12 9:54
indian14328-Jun-12 9:54 
GeneralRe: Storing file in a Stream rather than storing in the file Pin
jkirkerx28-Jun-12 10:30
professionaljkirkerx28-Jun-12 10:30 
Questioncreating Menus horizontal Pin
deeptul27-Jun-12 9:51
deeptul27-Jun-12 9:51 
AnswerRe: creating Menus horizontal Pin
R. Giskard Reventlov27-Jun-12 9:55
R. Giskard Reventlov27-Jun-12 9:55 
QuestionSplitting Large file in to Chunks Pin
indian14327-Jun-12 7:59
indian14327-Jun-12 7:59 
AnswerRe: Splitting Large file in to Chunks Pin
jkirkerx27-Jun-12 8:34
professionaljkirkerx27-Jun-12 8:34 
GeneralRe: Splitting Large file in to Chunks Pin
indian14327-Jun-12 10:12
indian14327-Jun-12 10:12 
GeneralRe: Splitting Large file in to Chunks Pin
jkirkerx27-Jun-12 10:46
professionaljkirkerx27-Jun-12 10:46 
GeneralRe: Splitting Large file in to Chunks Pin
indian14327-Jun-12 11:05
indian14327-Jun-12 11:05 
GeneralRe: Splitting Large file in to Chunks Pin
R. Giskard Reventlov27-Jun-12 10:30
R. Giskard Reventlov27-Jun-12 10:30 
GeneralRe: Splitting Large file in to Chunks Pin
indian14327-Jun-12 11:10
indian14327-Jun-12 11:10 
QuestionCalculations in vb.net Pin
Fiona Tan27-Jun-12 7:05
Fiona Tan27-Jun-12 7:05 
GeneralRe: Calculations in vb.net Pin
jkirkerx27-Jun-12 7:23
professionaljkirkerx27-Jun-12 7:23 
QuestionMultiple bookings using arraylist Pin
Fiona Tan27-Jun-12 7:03
Fiona Tan27-Jun-12 7:03 
AnswerRe: Multiple bookings using arraylist Pin
Sandeep Mewara27-Jun-12 8:13
mveSandeep Mewara27-Jun-12 8:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.