使用Process 启动发现 没有界面 界面办法如下
主要用到 Cjwdev.WindowsApi.dll
下载地址: 链接:https://pan.baidu.com/s/1R2AFVxLArZCkwCumlUxN1w 密码:4qhn
try { //appStartPath = "程序路径"; IntPtr userTokenHandle = IntPtr.Zero; ApiDefinitions.WTSQueryUserToken(ApiDefinitions.WTSGetActiveConsoleSessionId(), ref userTokenHandle); ApiDefinitions.PROCESS_INFORMATION procInfo = new ApiDefinitions.PROCESS_INFORMATION(); ApiDefinitions.STARTUPINFO startInfo = new ApiDefinitions.STARTUPINFO(); startInfo.cb = (uint)System.Runtime.InteropServices.Marshal.SizeOf(startInfo); ApiDefinitions.CreateProcessAsUser( userTokenHandle, appStartPath, "", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref startInfo, out procInfo); if (userTokenHandle != IntPtr.Zero) ApiDefinitions.CloseHandle(userTokenHandle); int _currentAquariusProcessId = (int)procInfo.dwProcessId; } catch (Exception ex) { }
参考 https://blog.csdn.net/Struggle_Cxg/article/details/83302251