问题描述
解决方案
using Cjwdev
using Cjwdev.WindowsApi
try
{
appStartPath= ‚C:\\ruhoo.exe„
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)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)
_currentAquariusProcessId = (int)procInfo.dwProcessId
}
catch (Exception ex)
{
MessageBox.Show(string.Format("Start Application failed, its path is {0} ,exception: {1}", appStartPath, ex.Message))
}