Property Sheet Handler Interface
Now that you know how a property sheet handler works, let’s discuss the interfaces involved in a little more detail.
IShellExtInit
The
implementation of IShellExtInit is exactly the
same as it was in Chapter 4. (For the details of
the IShellExtInit interface, see Section 4.4 in Chapter 4.)
Well, almost. The functionality provided by
IShellExtInit—which is used to determine
which files are selected in the Explorer—is generic enough to
be wrapped in a class. All future extensions that must implement
IShellExtInit in this book will use this class.
The class is called clsDropFiles, and the complete class listing is
shown in Example 6.1.
Example 6-1. clsDropFiles Class
Option Explicit Private m_nFiles As Long Private m_sDropFiles( ) As String Public Sub GetDropFiles(pDataObj As IDataObject, _ ByVal sExtension As String) Dim FmtEtc As FORMATETC Dim pMedium As STGMEDIUM Dim i As Long Dim lresult As Long Dim sTemp As String Dim lIndex As Long With FmtEtc .cfFormat = CF_HDROP .ptd = 0 .dwAspect = DVASPECT_CONTENT .lIndex = -1 .TYMED = TYMED_HGLOBAL End With pDataObj.GetData FmtEtc, pMedium m_nFiles = DragQueryFile(pMedium.pData, &HFFFFFFFF, _ vbNullString, 0) lIndex = 0 For i = 0 To m_nFiles - 1 sTemp = Space(255) lresult = DragQueryFile(pMedium.pData, i, sTemp, Len(sTemp)) If (lresult > 0) Then sTemp = Left$(sTemp, lresult) If LCase(Right(sTemp, 4)) = sExtension Then ReDim Preserve m_sDropFiles(lIndex + 1) m_sDropFiles(lIndex) = sTemp lIndex = lIndex ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access