• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PROCESS_INFORMATION类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PROCESS_INFORMATION的典型用法代码示例。如果您正苦于以下问题:C# PROCESS_INFORMATION类的具体用法?C# PROCESS_INFORMATION怎么用?C# PROCESS_INFORMATION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PROCESS_INFORMATION类属于命名空间,在下文中一共展示了PROCESS_INFORMATION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateProcess

        /// <summary>
        /// Creates the process.
        /// </summary>
        /// <param name="ProcessName">Name of the process.</param>
        /// <param name="CommandLine">The command line.</param>
        /// <exception cref="System.Exception">Failure</exception>
        public static void CreateProcess(string ProcessName, string CommandLine)
        {
            Log.WriteLine("CreateProcess(" + ProcessName + ", " + CommandLine + ")");
            STARTUPINFO SInfo = new STARTUPINFO();
            PROCESS_INFORMATION PInfo = new PROCESS_INFORMATION();
            Log.WriteLine("Try Connect to DBG");
            DbgUiConnectToDbg();
            Log.WriteLine("Try CreateProcess");
            if (!CreateProcess(null, new StringBuilder(ProcessName).Append(" ").Append(CommandLine), null, null, false, 0x1 | 0x2, null, null, ref SInfo, ref PInfo))
            {
                // May be must be run under Administrator.

                if (Global.IsAdministrator())
                {
                    Log.WriteLine("Creating process failed.");
                }
                else
                {
                    RestartWithAdministrator();
                }
            }
            Log.WriteLine("Try Stop Debugging");
            DbgUiStopDebugging(PInfo.hProcess);
            CloseHandle(PInfo.hProcess);
            CloseHandle(PInfo.hThread);
            Log.WriteLine("Created Process.");
        }
开发者ID:qcjxberin,项目名称:IFEOManage,代码行数:33,代码来源:Launcher.cs


示例2: Launch

        public static Debuggee Launch(string executable,
			string argumentString = null, string workingDirectory = null)
        {
            var si = new STARTUPINFO {
                cb = Marshal.SizeOf(typeof(STARTUPINFO)),
            };
            var pi = new PROCESS_INFORMATION();

            if (argumentString == string.Empty)
                argumentString = null;
            if (workingDirectory == string.Empty)
                workingDirectory = null;

            if (!API.CreateProcess(executable, argumentString, IntPtr.Zero, IntPtr.Zero, true,
                ProcessCreationFlags.CreateNewConsole | // Create extra console for the process
                ProcessCreationFlags.DebugOnlyThisProcess // Grant debugger access to the process
                ,IntPtr.Zero, workingDirectory, ref si, out pi))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            var dbg = new Debuggee(executable,
                pi.hProcess, pi.dwProcessId,
                pi.hThread, pi.dwThreadId,
                ExecutableMetaInfo.ExtractFrom(executable));

            return dbg;
        }
开发者ID:aBothe,项目名称:DDebugger,代码行数:28,代码来源:DDebugger.cs


示例3: CreateProcess

 public static extern bool CreateProcess(string lpApplicationName,
        string lpCommandLine, IntPtr lpProcessAttributes,
        IntPtr lpThreadAttributes,
        bool bInheritHandles, ProcessCreationFlags dwCreationFlags,
        IntPtr lpEnvironment, string lpCurrentDirectory,
        ref STARTUPINFO lpStartupInfo,
        out PROCESS_INFORMATION lpProcessInformation);
开发者ID:vans163,项目名称:linLauncher,代码行数:7,代码来源:proclauncher.cs


示例4: Run

 /// <summary>
 /// Runs the 
 /// </summary>
 public static void Run()
 {
     const uint NORMAL_PRIORITY_CLASS = 0x0020;
     string Path = Environment.CurrentDirectory + @"\" + (Program.projectName.ToString() == "Ultimatium" ? "BlackOpsMP.exe" : "iw5mp.exe");
     string Arguments = Program.Arguments;
     PROCESS_INFORMATION pInfo = new PROCESS_INFORMATION();
     STARTUPINFO sInfo = new STARTUPINFO();
     SECURITY_ATTRIBUTES pSec = new SECURITY_ATTRIBUTES();
     SECURITY_ATTRIBUTES tSec = new SECURITY_ATTRIBUTES();
     pSec.nLength = Marshal.SizeOf(pSec);
     tSec.nLength = Marshal.SizeOf(tSec);
     bool Initialized = CreateProcess(Path, Arguments,
     ref pSec, ref tSec, false, NORMAL_PRIORITY_CLASS,
     IntPtr.Zero, null, ref sInfo, out pInfo);
     if (Initialized)
     {
         Log.Write("Launching " + Program.projectName + "...");
         Log.Write("Successful launch. PID: " + pInfo.dwProcessId);
         Log.Write("Happy gaming!");
         Environment.Exit(0x0);
     }
     else
     {
         Log.Write("ERROR: Could not launch " + Program.projectName + ". Press any key to exit.");
         Console.ReadKey();
         Environment.Exit(0x3);
     }
 }
开发者ID:GammaForce,项目名称:Updater,代码行数:31,代码来源:Launcher.cs


示例5: StartProcessAsCurrentUser

        public static bool StartProcessAsCurrentUser(string appPath, string cmdLine = null, string workDir = null, bool visible = true)
        {
            var hUserToken = IntPtr.Zero;
            var startInfo = new STARTUPINFO();
            var procInfo = new PROCESS_INFORMATION();
            var pEnv = IntPtr.Zero;
            int iResultOfCreateProcessAsUser;

            startInfo.cb = Marshal.SizeOf(typeof(STARTUPINFO));

            try
            {
                if (!GetSessionUserToken(ref hUserToken))
                {
                    throw new Exception("StartProcessAsCurrentUser: GetSessionUserToken failed.");
                }

                uint dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | (uint)(visible ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW);
                startInfo.wShowWindow = (short)(visible ? SW.SW_SHOW : SW.SW_HIDE);
                startInfo.lpDesktop = "winsta0\\default";

                if (!CreateEnvironmentBlock(ref pEnv, hUserToken, false))
                {
                    throw new Exception("StartProcessAsCurrentUser: CreateEnvironmentBlock failed.");
                }

                if (!CreateProcessAsUser(hUserToken,
                    appPath, // Application Name
                    cmdLine, // Command Line
                    IntPtr.Zero,
                    IntPtr.Zero,
                    false,
                    dwCreationFlags,
                    pEnv,
                    workDir, // Working directory
                    ref startInfo,
                    out procInfo))
                {
                    throw new Exception("StartProcessAsCurrentUser: CreateProcessAsUser failed.\n");
                }

                iResultOfCreateProcessAsUser = Marshal.GetLastWin32Error();
            }
            finally
            {
                CloseHandle(hUserToken);
                if (pEnv != IntPtr.Zero)
                {
                    DestroyEnvironmentBlock(pEnv);
                }
                CloseHandle(procInfo.hThread);
                CloseHandle(procInfo.hProcess);
            }

            return true;
        }
开发者ID:supergonzales,项目名称:CreateProcessAsUser,代码行数:56,代码来源:ProcessExtensions.cs


示例6: CreateProcess

 public static extern bool CreateProcess(StringBuilder lpApplicationName, StringBuilder lpCommandLine,
     SECURITY_ATTRIBUTES lpProcessAttributes,
     SECURITY_ATTRIBUTES lpThreadAttributes,
     bool bInheritHandles,
     int dwCreationFlags,
     StringBuilder lpEnvironment,
     StringBuilder lpCurrentDirectory,
     ref STARTUPINFO lpStartupInfo,
     ref PROCESS_INFORMATION lpProcessInformation
     );
开发者ID:icaca,项目名称:launcher,代码行数:10,代码来源:frmLauncher.cs


示例7: CreateProcess

 public static extern bool CreateProcess(String imageName,
     String cmdLine,
     IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes,
     bool boolInheritHandles,
     uint dwCreationFlags,
     IntPtr lpEnvironment,
     String lpszCurrentDir,
     ref STARTUPINFO si,
     out PROCESS_INFORMATION pi);
开发者ID:alexisjojo,项目名称:tibiaezbot,代码行数:10,代码来源:WinApi.cs


示例8: CreateProcess

 internal static extern bool CreateProcess(
     [MarshalAs(UnmanagedType.LPTStr)] string lpApplicationName,
     StringBuilder lpCommandLine,
     ref SECURITY_ATTRIBUTES procSecAttrs,
     ref SECURITY_ATTRIBUTES threadSecAttrs,
     bool bInheritHandles,
     int dwCreationFlags,
     IntPtr lpEnvironment,
     [MarshalAs(UnmanagedType.LPTStr)] string lpCurrentDirectory,
     STARTUPINFO lpStartupInfo,
     PROCESS_INFORMATION lpProcessInformation
 );
开发者ID:noahfalk,项目名称:corefx,代码行数:12,代码来源:Interop.CreateProcess.cs


示例9: CreateProcess

		static extern bool CreateProcess(
			string lpApplicationName,
			string lpCommandLine,
			IntPtr lpProcessAttributes,
			IntPtr lpThreadAttributes,
			[MarshalAs(UnmanagedType.Bool)] bool bInheritHandles,
			uint dwCreationFlags,
			IntPtr lpEnvironment,
			string lpCurrentDirectory,
			[In] ref StartupInfo lpStartupInfo,
			out PROCESS_INFORMATION lpProcessInformation
		);
开发者ID:nylen,项目名称:SharpDevelop,代码行数:12,代码来源:GitVersionProvider.cs


示例10: RunProcess

        private string RunProcess(string id, string command)
        {
            try {
                IntPtr dupedToken = new IntPtr(0);

                SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
                sa.bInheritHandle = false;
                sa.Length = Marshal.SizeOf(sa);
                sa.lpSecurityDescriptor = (IntPtr)0;

                var token = WindowsIdentity.GetCurrent().Token;

                const uint GENERIC_ALL = 0x10000000;

                const int SecurityImpersonation = 2;
                const int TokenType = 1;

                var ret = DuplicateTokenEx(token, GENERIC_ALL, ref sa, SecurityImpersonation, TokenType, ref dupedToken);
                if (ret == false)
                    throw new Exception("DuplicateTokenEx failed (" + Marshal.GetLastWin32Error() + ")");

                STARTUPINFO si = new STARTUPINFO();
                si.cb = Marshal.SizeOf(si);
                si.lpDesktop = "";
                PROCESS_INFORMATION pi = new PROCESS_INFORMATION();

                uint exitCode;
                try {
                    ret = CreateProcessAsUser(dupedToken, null, @"c:\windows\system32\shutdown.exe " + command + " /m " + id, ref sa, ref sa, false, 0, (IntPtr)0, "c:\\", ref si, out pi);

                    if (ret == false)
                        throw new Exception("CreateProcessAsUser failed (" + Marshal.GetLastWin32Error() + ")");

                    WaitForSingleObject(pi.hProcess, 10000);
                    GetExitCodeProcess(pi.hProcess, out exitCode);
                }
                catch (Exception ex) {
                    throw ex;
                }
                finally {
                    CloseHandle(pi.hProcess);
                    CloseHandle(pi.hThread);
                    CloseHandle(dupedToken);
                }

                if (exitCode == 0)
                    return "";
                return "Exit code: " + exitCode;
            }
            catch (Exception ex) {
                return ex.Message;
            }
        }
开发者ID:saxx,项目名称:WolWeb,代码行数:53,代码来源:ShutdownController.cs


示例11: CreateProcessWithLogonW

 internal static extern bool CreateProcessWithLogonW(
     string userName,
     string domain,
     string passwordInClearText,
     LogonFlags logonFlags,
     [MarshalAs(UnmanagedType.LPTStr)] string appName,
     StringBuilder cmdLine,
     int creationFlags,
     IntPtr environmentBlock,
     [MarshalAs(UnmanagedType.LPTStr)] string lpCurrentDirectory,
     STARTUPINFO lpStartupInfo,
     PROCESS_INFORMATION lpProcessInformation);
开发者ID:Czapek83,项目名称:corefx,代码行数:12,代码来源:Interop.CreateProcessWithLogon.cs


示例12: CreateProcessAsUser

 public static extern bool CreateProcessAsUser(
 IntPtr hToken,
 string lpApplicationName,
 string lpCommandLine,
 ref SECURITY_ATTRIBUTES lpProcessAttributes,
 ref SECURITY_ATTRIBUTES lpThreadAttributes,
 bool bInheritHandles,
 uint dwCreationFlags,
 IntPtr lpEnvironment,
 string lpCurrentDirectory,
 ref STARTUPINFO lpStartupInfo,
 out PROCESS_INFORMATION lpProcessInformation);
开发者ID:terryfan1109,项目名称:win32-test,代码行数:12,代码来源:Win32.Process.cs


示例13: CreateProcessAsUser

 public static extern Boolean CreateProcessAsUser(
     IntPtr hToken,
     String lpApplicationName,
     String lpCommandLine,
     IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes,
     Boolean bInheritHandles,
     Int32 dwCreationFlags,
     IntPtr lpEnvironment,
     String lpCurrentDirectory,
     ref STARTUPINFO lpStartupInfo,
     out PROCESS_INFORMATION lpProcessInformation
     );
开发者ID:CNU-Developers,项目名称:CNUServiceAndUpdator,代码行数:13,代码来源:Win32ProcessCall.cs


示例14: CreateProcessWithLogonW

 public static extern Boolean CreateProcessWithLogonW(
     String lpszUsername,
     String lpszDomain,
     String lpszPassword,
     Int32 dwLogonFlags,
     String applicationName,
     String commandLine,
     Int32 creationFlags,
     IntPtr environment,
     String currentDirectory,
     ref STARTUPINFO sui,
     out PROCESS_INFORMATION processInfo
     );
开发者ID:CNU-Developers,项目名称:CNUServiceAndUpdator,代码行数:13,代码来源:Win32ProcessCall.cs


示例15: Main

        static int Main(string[] args)
        {
            var exe = Assembly.GetExecutingAssembly().Location;
            var dir = Path.GetDirectoryName(exe);
            var name = Path.GetFileNameWithoutExtension(exe);

            var configPath = Path.Combine(dir, name + ".shim");
            if(!File.Exists(configPath)) {
                Console.Error.WriteLine("Couldn't find " + Path.GetFileName(configPath) + " in " + dir);
                return 1;
            }

            var config = Config(configPath);
            var path = Get(config, "path");
            var add_args = Get(config, "args");

            var si = new STARTUPINFO();
            var pi = new PROCESS_INFORMATION();

            // create command line
            var cmd_args = add_args ?? "";
            var pass_args = Serialize(args);
            if(!string.IsNullOrEmpty(pass_args)) {
                if(!string.IsNullOrEmpty(cmd_args)) cmd_args += " ";
                cmd_args += pass_args;
            }
            if(!string.IsNullOrEmpty(cmd_args)) cmd_args = " " + cmd_args;
            var cmd = "\"" + path + "\"" + cmd_args;

            if(!CreateProcess(null, cmd, IntPtr.Zero, IntPtr.Zero,
                bInheritHandles: true,
                dwCreationFlags: 0,
                lpEnvironment: IntPtr.Zero, // inherit parent
                lpCurrentDirectory: null, // inherit parent
                lpStartupInfo: ref si,
                lpProcessInformation: out pi)) {

                return Marshal.GetLastWin32Error();
            }

            WaitForSingleObject(pi.hProcess, INFINITE);

            uint exit_code = 0;
            GetExitCodeProcess(pi.hProcess, out exit_code);

            // Close process and thread handles.
            CloseHandle(pi.hProcess);
            CloseHandle(pi.hThread);

            return (int)exit_code;
        }
开发者ID:nikolasd,项目名称:scoop,代码行数:51,代码来源:shim.cs


示例16: CreateProcess

 private static extern bool CreateProcess(
     [MarshalAs(UnmanagedType.LPTStr)]
     string lpApplicationName,
     string lpCommandLine,
     IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes,
     bool bInheritHandles,
     int dwCreationFlags,
     IntPtr lpEnvironment,
     [MarshalAs(UnmanagedType.LPTStr)]
     string lpCurrentDirectory,
     STARTUPINFO lpStartupInfo,
     ref PROCESS_INFORMATION lpProcessInformation
 );
开发者ID:Ricordanza,项目名称:poderosa,代码行数:14,代码来源:PipeCreator.cs


示例17: inject

 public DLLInformation inject(string exePath, string dllPath)
 {
     DLLInformation d = new DLLInformation();
     STARTUPINFO lpStartupInfo = new STARTUPINFO();
     PROCESS_INFORMATION lpProcessInfo = new PROCESS_INFORMATION();
     SECURITY_ATTRIBUTES lpSecurityAttributes1 = new SECURITY_ATTRIBUTES();
     SECURITY_ATTRIBUTES lpSecurityAttributes2 = new SECURITY_ATTRIBUTES();
     lpSecurityAttributes1.nLength = Marshal.SizeOf(lpSecurityAttributes1);
     lpSecurityAttributes2.nLength = Marshal.SizeOf(lpSecurityAttributes2);
     IntPtr hProcess;
     CreateProcess(exePath, "", ref lpSecurityAttributes1, ref lpSecurityAttributes2, false, 0x0020, IntPtr.Zero, null, ref lpStartupInfo, out lpProcessInfo);
     hProcess = OpenProcess((int)(0x000F0000L | 0x00100000L | 0xFFF), false, lpProcessInfo.dwProcessId);
     d.ProcID = lpProcessInfo.dwProcessId;
     d.ErrorCode = commonInject(hProcess, dllPath, ref d);
     return d;
 }
开发者ID:aevv,项目名称:aevvinject,代码行数:16,代码来源:Injector.cs


示例18: CreateProc

        //Initialization
        //        static uint SW_SHOW = 5;
        public static PROCESS_INFORMATION CreateProc(string fullCommand)
        {
            STARTUPINFO si = new STARTUPINFO();
            PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
            CreateProcess(
                null,
                fullCommand,
                IntPtr.Zero,
                IntPtr.Zero,
                false,
                0,
                IntPtr.Zero,
                null,
                ref si,
                out pi);

            return pi;
        }
开发者ID:jlami,项目名称:mutefm,代码行数:20,代码来源:Operation.cs


示例19: Run

        public static void Run(out String status, out String identity, String cmdline, String startfrom)
        {
            bool      ret = false;

            identity = CurrentUserName;

            SECURITY_ATTRIBUTES sa  = new SECURITY_ATTRIBUTES();
            sa.bInheritHandle       = false;
            sa.Length               = Marshal.SizeOf(sa);
            sa.lpSecurityDescriptor = (IntPtr)0;

            STARTUPINFO si          = new STARTUPINFO();
            si.cb                   = Marshal.SizeOf(si);
            si.lpDesktop            = "";

            string commandLinePath;
            commandLinePath = cmdline;

            PROCESS_INFORMATION pi  = new PROCESS_INFORMATION();
            ret = CreateProcess(
                null,			//LPCTSTR lpApplicationName,
                cmdline,		//LPTSTR lpCommandLine,
                ref sa,			//LPSECURITY_ATTRIBUTES lpProcessAttributes,
                ref sa,			//LPSECURITY_ATTRIBUTES lpThreadAttributes,
                false,			//BOOL bInheritHandles,
                0,				//DWORD dwCreationFlags,
                (IntPtr)0,		//LPVOID lpEnvironment,
                startfrom,		//LPCTSTR lpCurrentDirectory,
                ref si,			//LPSTARTUPINFO lpStartupInfo,
                out pi);		//LPPROCESS_INFORMATION lpProcessInformation

            if (ret == false)
            {
                status = "CreateProcess failed with " + Marshal.GetLastWin32Error();
            }
            else
            {
                status = "CreateProcess SUCCESS.  The child PID is" + pi.dwProcessId;

                CloseHandle(pi.hProcess);
                CloseHandle(pi.hThread);
            }
        }
开发者ID:nevali,项目名称:aaf,代码行数:43,代码来源:RunAndPlay.cs


示例20: LaunchCommand1

        public static void LaunchCommand1(string strCommand, string strDomain, string strName, string strPassword)
        {
            // Variables
            PROCESS_INFORMATION processInfo = new PROCESS_INFORMATION();
            STARTUPINFO startInfo = new STARTUPINFO();
            bool bResult = false;
            UInt32 uiResultWait = WAIT_FAILED;

            try
            {
                // Create process
                startInfo.cb = Marshal.SizeOf(startInfo);

                bResult = CreateProcessWithLogonW(
                    strName,
                    strDomain,
                    strPassword,
                    0,
                    null,
                    strCommand,
                    0,
                    IntPtr.Zero,
                    null,
                    ref startInfo,
                    out processInfo
                );
                if (!bResult) { throw new Exception("CreateProcessWithLogonW error #" + Marshal.GetLastWin32Error().ToString()); }

                // Wait for process to end
                uiResultWait = WaitForSingleObject(processInfo.hProcess, INFINITE);
                if (uiResultWait == WAIT_FAILED) { throw new Exception("WaitForSingleObject error #" + Marshal.GetLastWin32Error()); }

            }
            finally
            {
                // Close all handles
                CloseHandle(processInfo.hProcess);
                CloseHandle(processInfo.hThread);
            }
        }
开发者ID:CNU-Developers,项目名称:CNUServiceAndUpdator,代码行数:40,代码来源:Win32ProcessCall.cs



注:本文中的PROCESS_INFORMATION类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PRoConClient类代码示例发布时间:2022-05-24
下一篇:
C# PPos类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap