Beispiel #1
0
        public static bool CreateProcess(String ExeName, String CmdLine)
        {
            Int32 INFINITE;

            unchecked { INFINITE = (int)0xFFFFFFFF; }
            ProcessInfo pi = new ProcessInfo();

            if (CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
                              0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi) == 0)
            {
                return(false);
            }

            WaitForSingleObject(pi.hProcess, INFINITE);
            Int32 exitCode;

            if (GetExitCodeProcess(pi.hProcess, out exitCode) == 0)
            {
                //Log.Error( "Failure in GetExitCodeProcess" );
                WinCeApi.CloseHandle(pi.hThread);
                WinCeApi.CloseHandle(pi.hProcess);
                return(false);
            }

            WinCeApi.CloseHandle(pi.hThread);
            WinCeApi.CloseHandle(pi.hProcess);
            if (exitCode != 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Kills (terminates) this process
        /// </summary>
        public void Kill()
        {
            IntPtr hProcess;

            hProcess = OpenProcess(PROCESS_TERMINATE, false, (int)handle);

            if (hProcess != (IntPtr)INVALID_HANDLE_VALUE)
            {
                bool bRet;
                bRet = TerminateProcess(hProcess, 0);
                WinCeApi.CloseHandle(hProcess);
            }
        }