zoukankan      html  css  js  c++  java
  • C# 守护进程 Windows服务 启动 exe

    使用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

  • 相关阅读:
    C# Dev PropertyGrid
    C# PropertyGrid控件应用心得
    FileWriter不覆盖
    FileWriter
    java试题
    Java线程池
    java自带线程池和队列详细讲解
    HashMap练习题
    Map集合
    java指定
  • 原文地址:https://www.cnblogs.com/su-king/p/13391994.html
Copyright © 2011-2022 走看看