安装一个windows服务应用程序,
并且在安装过程中将该服务的属性“允许服务与桌面交互”设置为true。有思路的同志请尽量说详细点,
因为我很初级,很可能不知道对您的思路该如何开始。谢谢。

解决方案 »

  1.   

    如果有在其他阶段,比方说服务启动阶段将该“允许服务与桌面交互”设置为true的方法,也可以说说看我只是希望由程序来完成这个设置过程。
      

  2.   

    恐怕得通过 API来实现:
    OpenService
    ChangeServiceConfig
      

  3.   

    [DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
    public static extern bool ChangeServiceConfig(IntPtr serviceHandle, int serviceType, int startType, int errorControl, string binaryPath, string loadOrderGroup, IntPtr pTagId, char[] dependencies, string userName, string password, string displayName);[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
    public static extern IntPtr OpenService(IntPtr databaseHandle, string serviceName, int access);[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
    public static extern IntPtr OpenSCManager(string machineName, string databaseName, int access);
     
      

  4.   

    http://blog.blogchina.com/websites/1038731.html
      

  5.   

    re: lookfeng() ( ) 信誉:91 
    [DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
    public static extern bool ChangeServiceConfig(IntPtr serviceHandle, int serviceType, int startType, int errorControl, string binaryPath, string loadOrderGroup, IntPtr pTagId, char[] dependencies, string userName, string password, string displayName);这个api里涉及的参数太多,要回去找个api的参考书来看看才知道啊。thx 先re: zyno2() ( ) 信誉:100 你给出的地址所讲的答案基本上只是理论正确,实际行不通(!)。尤其是最后行
    =======
    System.ServiceProcess.ServiceType  =  InteractiveProcess;
    =======
    System.ServiceProcess.ServiceType是一个类,而非指ServiceProcess的一个属性ServiceType。一个ServiceProcess实例的ServiceType状态是作为属性保存给ProcessController的,所以即使要使用ServiceType属性,也是ProcessController的实例,行如
    myController.ServiceType=ServiceType.InteractiveProcess;
    但这也是不可行的,因为ServiceType只读。
      

  6.   

    http://www.codeproject.com/csharp/cswindowsservicedesktop.asp