Esempio n. 1
0
        private void LoadConEmuDll(string asLibrary)
        {
            if (ConEmuCD != IntPtr.Zero)
            {
                return;
            }

            ConEmuCD = LoadLibrary(asLibrary);
            if (ConEmuCD == IntPtr.Zero)
            {
                int errorCode = Marshal.GetLastWin32Error();
                throw new GuiMacroException(string.Format("Can't load library, ErrCode={0}\n{1}", errorCode, asLibrary));
            }

            // int __stdcall ConsoleMain3(int anWorkMode/*0-Server&ComSpec,1-AltServer,2-Reserved*/, LPCWSTR asCmdLine)
            const string fnName    = "ConsoleMain3";
            IntPtr       exportPtr = GetProcAddress(ConEmuCD, fnName);

            if (exportPtr == IntPtr.Zero)
            {
                UnloadConEmuDll();
                throw new GuiMacroException(string.Format("Function {0} not found in library\n{1}\nUpdate ConEmu modules", fnName, asLibrary));
            }
            ConsoleMain3 = (CConsoleMain3)Marshal.GetDelegateForFunctionPointer(exportPtr, typeof(CConsoleMain3));
            // To call: ConsoleMain3.Invoke(0, cmdline);
        }
Esempio n. 2
0
        private void LoadConEmuDll(string asLibrary)
        {
            if (ConEmuCD != IntPtr.Zero)
            {
                return;
            }

            ConEmuCD = LoadLibrary(asLibrary);
            if (ConEmuCD == IntPtr.Zero)
            {
                int errorCode = Marshal.GetLastWin32Error();
                throw new GuiMacroException(string.Format("Can't load library, ErrCode={0}\n{1}", errorCode, asLibrary));
            }

            // int __stdcall ConsoleMain3(int anWorkMode/*0-Server&ComSpec,1-AltServer,2-Reserved*/, LPCWSTR asCmdLine)
            const string fnName = "ConsoleMain3";
            IntPtr exportPtr = GetProcAddress(ConEmuCD, fnName);
            if (exportPtr == IntPtr.Zero)
            {
                UnloadConEmuDll();
                throw new GuiMacroException(string.Format("Function {0} not found in library\n{1}\nUpdate ConEmu modules", fnName, asLibrary));
            }
            ConsoleMain3 = (CConsoleMain3)Marshal.GetDelegateForFunctionPointer(exportPtr, typeof(CConsoleMain3));
            // To call: ConsoleMain3.Invoke(0, cmdline);
        }