none
Copy Hook Handler RRS feed

  • Question

  • I have the following 2 codes in one of my classes. I am trying to register the copy hook handler, but I have no idea what "ByVal t as Type" is expecting me to input when I go to run the method.  I know what an integer, string, double, etc. are, but what is a type expecting?  It says in the comments that someone else put there, not me, that it is expecting a COM class...('' <param name="t">COM class</param>) I have no idea if it means one of the COM's I have declared or what.  Thanks for the help!

    Public Shared Sub RegisterShellExtCopyHookHandler(ByVal t As Type)

    Dim keyName As String = String.Format("Software\Classes\Directory\shellex\CopyHookHandlers\Test")
    Using key As RegistryKey = Registry.CurrentUser.CreateSubKey(keyName)
    ' Set the default value of the key.
    If key IsNot Nothing Then
    key.SetValue(Nothing, String.Format("{0}", t.GUID.ToString("B").ToUpper()))
    End If
    End Using
    End Sub

            ''' <summary>
            ''' Unregister the context menu handler.
            ''' </summary>
            ''' <param name="t">COM class</param>
            ''' <param name="fileType">
            ''' The file type that the context menu handler is associated with. For 
            ''' example, '*' means all file types; '.txt' means all .txt files. The 
            ''' parameter must not be NULL or an empty string. 
            ''' </param>
            Public Shared Sub UnregisterShellExtContextMenuHandler(ByVal t As String)
                '            
                '            string keyName = string.Format(@"Software\Classes\Directory\shellex\CopyHookHandlers\Cyberduck");
                '            Registry.CurrentUser.DeleteSubKeyTree(keyName);

                Dim keyName As String = String.Format("Directory\shellex\CopyHookHandlers\Test")
                Registry.ClassesRoot.DeleteSubKeyTree(keyName)

                keyName = String.Format("Software\Classes\CLSID\{0}", t.GUID.ToString("B").ToUpper())
                Registry.CurrentUser.DeleteSubKeyTree(keyName)
            End Sub

    this is my other class

    Namespace ShellExtCopyHookHandler
    <ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214e8-0000-0000-c000-000000000046")>
    Friend Interface IShellExtInit
    Sub Initialize(ByVal pidlFolder As IntPtr, ByVal pDataObj As IntPtr, ByVal hKeyProgID As IntPtr)
    End Interface

    <ComVisible(False), ComImport, Guid("000214FC-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
    Public Interface ICopyHookW
    <PreserveSig()>
    Function CopyCallback(ByVal hwnd As IntPtr, ByVal wFunc As UInteger, ByVal wFlags As UInteger, ByVal pszSrcFile As String, ByVal dwSrcAttribs As UInt32, ByVal pszDestFile As String, ByVal dwDestAttribs As UInt32) As UInteger
    End Interface

    Friday, February 16, 2018 11:17 PM

Answers

  • I have the following 2 codes in one of my classes. I am trying to register the copy hook handler, but I have no idea what "ByVal t as Type" is expecting me to input when I go to run the method.

    What is the "t As Type" that you are referring to?  The parameter t is described in the comments as 'COM Class' and the parameter list for the method spcifies that parameter type as a String.  But the comments don't match the parameter list, because there is no parameter named 'fileType'.  You should confirm the exact signature required for the method, and adjust the comments if necessary.

    • Marked as answer by RuthlessMike Sunday, May 12, 2019 2:06 AM
    Saturday, February 17, 2018 12:15 AM