Results 1 to 5 of 5

Thread: [twinBASIC] Dump all file properties/metadata visible to Explorer to text file

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,243

    [twinBASIC] Dump all file properties/metadata visible to Explorer to text file


    PropDumper v1.0

    This program will create a dump of all properties and metadata visible to Explorer which aren't blank for the given file.

    You can create these output files with the specified extension, in the same folder where the file resides or a central folder. If the output already exists, there's an option to rename to the next available name the same way Windows does, File (1).txt, File (2).txt, whatever number is available.

    Properties include hidden Unicode codepoints indicating whether it's left to right or right to left; I usually view text in Notepad with Western script instead of Unicode, so I find it useful to remove these. So that option is there.

    This will not go into zip/cab files, even though Windows considers them folders now.

    This is all done by using the Windows Property System (IPropertyStore et al), which is the system that underlies how all the properties are displayed in Explorer-- so you're able to list exactly what Explorer is, without having to worry about having to derive things like image width/height yourself. If Explorer can see it, it will be in the dump. Note: Some properties like Office are derived through 64bit shell extensions that won't load into 32bit apps; so if you want to make sure it's an identical representation, use the 64bit build for 64bit Windows.

    I made this project primarily to test things in my tbShellLib library, a collection of Windows shell interfaces and other COM components that's a 64bit compatible successor my oleexp.tlb project for VB6. Note that this is why the source code file is so large; it imports the entire library. Which is quite expansive.

    (Note that since this project uses new language features in tB, it would take some work to backport it to VB6).


    Requirements

    Windows 7+

    Source and binaries are self-contained, no installation or additional dependencies.

    Building from source requires twinBASIC Beta 147 or newer.


    Dumping properties


    Windows shell interfaces and Property System make dumping properties very easy:

    Code:
    Private Sub DumpFileProperties(siFile As IShellItem, sName As String)
        Dim sOut As String
        Dim lpPath As LongPtr, sPath As String
        siFile.GetDisplayName SIGDN_FILESYSPATH, lpPath
        sPath = LPWSTRtoStr(lpPath)
    
        
        sOut = "Filename: " & sName & vbCrLf
        sOut &= "File full path: " & sPath & vbCrLf
    
        Dim si2 As IShellItem2
        Dim pps As IPropertyStore
        Dim ppd As IPropertyDescription
        Dim lpFmt As LongPtr, sPropFmt As String
        Dim sFileOut As String
        
        If bCurDir Then
            sFileOut = sPath & sExt
        Else
            sFileOut = sPathOut & sExt
        End If
        If PathFileExistsW(sFileOut) Then
            If chkRename.Value = vbChecked Then
                sFileOut = UniqueNameInSeq(sFileOut)
            Else
                AppendLog "Skipping " & sName & "; output file exists."
                Exit Sub
            End If
        End If
        
        Set si2 = siFile
        si2.GetPropertyStore GPS_DEFAULT Or GPS_BESTEFFORT Or GPS_OPENSLOWITEM, IID_IPropertyStore, pps
        If (pps Is Nothing) = False Then
            Dim nMax As Long
            pps.GetCount nMax
            If nMax Then
            	AppendLog "Dumping " & nMax & " properties for " & sName & "..."
                    
                Dim i As Long
                Dim pk As PROPERTYKEY
                Dim lpProp As LongPtr, sProp As String
                Dim lpPropC As LongPtr, sPropC As String
                Dim lpPropN As LongPtr, sPropN As String
                For i = 0 To nMax - 1
                    pps.GetAt i, pk
                    If pk.fmtid.Data1 <> 0 Then
                        PSGetPropertyDescription pk, IID_IPropertyDescription, ppd
                        If (ppd Is Nothing) = False Then
                            ppd.GetDisplayName lpPropN
                            sPropN = LPWSTRtoStr(lpPropN)
                            ppd.GetCanonicalName lpPropC
                            sPropC = LPWSTRtoStr(lpPropC)
                            PSFormatPropertyValue ObjPtr(pps), ObjPtr(ppd), PDFF_DEFAULT, lpProp
                            sProp = LPWSTRtoStr(lpProp)
                            If bRemoveFmt Then RemoveFormatChars(sProp)
                            If sProp <> "" Then sOut &= sPropN & " (" & sPropC & ")=" & sProp & vbCrLf
                        Else
                            Debug.Print "Couldn't get propdesc for " & dbg_PKEYToString(pk)
                        End If
                    End If
                Next i
            Else
                sOut &= "No properties listed for file."
            End If
        Else
            AppendLog "Couldn't open property store for " & sPath
            sOut &= "Couldn't open property store for this file."
        End If
        
    
        WriteStrToFile sOut, sFileOut
        nCount = nCount + 1
    End Sub
    This project is also on GitHub.
    Attached Files Attached Files

  2. #2
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,488

    Re: [twinBASIC] Dump all file properties/metadata visible to Explorer to text file

    Do you fancy making a VB6 version so that the greater world at large can see the differencies between a VB6 and a TB implementation of the same program? It would be useful as a reference and a guide and it would serve as a demonstration of how much 'better' a TB implementation is and why. Could act as inspiration and a guide for others to do the same.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,243

    Re: [twinBASIC] Dump all file properties/metadata visible to Explorer to text file

    I've already done a few of those...

    https://www.vbforums.com/showthread....tivity-Monitor

    https://www.vbforums.com/showthread....x64-interfaces

    https://www.vbforums.com/showthread....64-bit-Windows (which can be built for either 32bit or 64bit has a VB6 implementation for 32bit)

    I mainly wanted to test my tbShellLib interfaces; there's no direct VB6 equivalent for that, only TLBs. So this was built from the ground up to use new tB language features, rather than simply run a VB6 version.

    To run this one in VB6 you'd need to change the LongPtr's back to Long, remove the PtrSafe keyword from API declares, change the DeclareWide APIs to regular Declare/switch As String to As Long/use StrPtr, reference oleexp.tlb/add mIID.bas, remove the 'Handles...' from control events, and replace the &= operator usage (stringvar &= "more text" vs stringvar = stringvar & "more text").
    Also Dim pKFM As IKnownFolderManager = CreateObject(sCLSID_KnownFolderManager) would be Dim pKFM As New KnownFolderManager, one thing better in the VB version, since unfortunately tB doesn't support coclasses yet (unless in TLBs). Same for IFileOpenDialog.
    Finally you'd need a tool like LaVolpe's Manifest Creator to put in the comctl6 visual styles manifest that tB inserts by default.

    I'll attach a version that's done all that. Since VB doesn't have a single-source structure, this doesn't include oleexp.tlb or mIID.bas, you'll need to set those up if you don't have them already, and add them (oleexp project thread).
    Attached Files Attached Files
    Last edited by fafalone; Oct 15th, 2022 at 03:09 PM.

  4. #4
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,488

    Re: [twinBASIC] Dump all file properties/metadata visible to Explorer to text file

    VERY good. Thanks.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,243

    Re: [twinBASIC] Dump all file properties/metadata visible to Explorer to text file

    The VB6 version you could I believe import into twinBASIC and run as-is with no modifications. 32bit only, of course.

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