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

  • 相关阅读:
    ReentrantLock和AQS
    CAS
    java8中ConcurrentHashMap
    java8中的HashMap
    TCP和UDP
    慢查询日志和profiling
    explain的使用
    select、poll、epoll之间的区别
    I/O模型
    生产者-消费者模式
  • 原文地址:https://www.cnblogs.com/su-king/p/13391994.html
Copyright © 2011-2022 走看看