Example #1
0
        public static void InitShellBrowserHook_old(IShellBrowser shellBrowser)
        {
            lock (typeof(HookLibManager))
            {
                if (fShellBrowserIsHooked || hHookLib == IntPtr.Zero)
                {
                    return;
                }
                IntPtr pFunc = PInvoke.GetProcAddress(hHookLib, "InitShellBrowserHook");
                if (pFunc == IntPtr.Zero)
                {
                    return;
                }
                InitShellBrowserHookDelegate initShellBrowserHook = (InitShellBrowserHookDelegate)
                                                                    Marshal.GetDelegateForFunctionPointer(pFunc, typeof(InitShellBrowserHookDelegate));
                IntPtr pShellBrowser = Marshal.GetComInterfaceForObject(shellBrowser, typeof(IShellBrowser));
                if (pShellBrowser == IntPtr.Zero)
                {
                    return;
                }
                int retcode = -1;
                try {
                    retcode = initShellBrowserHook(pShellBrowser);
                }
                catch (Exception e) {
                    QTUtility2.MakeErrorLog(e, "");
                }
                finally {
                    Marshal.Release(pShellBrowser);
                }
                if (retcode != 0)
                {
                    QTUtility2.MakeErrorLog(null, "InitShellBrowserHook failed: " + retcode);

                    MessageForm.Show(IntPtr.Zero,
                                     String.Format(
                                         "{0}: {1} {2}",
                                         QTUtility.TextResourcesDic["ErrorDialogs"][4],
                                         QTUtility.TextResourcesDic["ErrorDialogs"][6],
                                         QTUtility.TextResourcesDic["ErrorDialogs"][7]
                                         ),
                                     QTUtility.TextResourcesDic["ErrorDialogs"][1],
                                     MessageBoxIcon.Hand, 30000, false, true
                                     );
                }
                else
                {
                    fShellBrowserIsHooked = true;
                }
            }
        }
Example #2
0
        public static void InitShellBrowserHook(IShellBrowser shellBrowser)
        {
            lock (typeof(HookLibManager)) {
                if (fShellBrowserIsHooked || hHookLib == IntPtr.Zero)
                {
                    return;
                }
                IntPtr pFunc = PInvoke.GetProcAddress(hHookLib, "InitShellBrowserHook");
                if (pFunc == IntPtr.Zero)
                {
                    return;
                }
                InitShellBrowserHookDelegate initShellBrowserHook = (InitShellBrowserHookDelegate)
                                                                    Marshal.GetDelegateForFunctionPointer(pFunc, typeof(InitShellBrowserHookDelegate));
                IntPtr pShellBrowser = Marshal.GetComInterfaceForObject(shellBrowser, typeof(IShellBrowser));
                if (pShellBrowser == IntPtr.Zero)
                {
                    return;
                }
                int retcode = -1;
                try {
                    retcode = initShellBrowserHook(pShellBrowser);
                }
                catch (Exception e) {
                    QTUtility2.MakeErrorLog(e, "");
                }
                finally {
                    Marshal.Release(pShellBrowser);
                }
                if (retcode != 0)
                {
                    QTUtility2.MakeErrorLog(null, "InitShellBrowserHook failed: " + retcode);

                    // TODO: Localize this
                    MessageForm.Show(IntPtr.Zero,
                                     "Error:  Unable to initialize QTTabBar hook library.  " +
                                     "Some features might not be functional.  " +
                                     "You may need to reinstall the applicaiton.",
                                     "Error", MessageBoxIcon.Hand, 30000, false, true);
                }
                else
                {
                    fShellBrowserIsHooked = true;
                }
            }
        }