安装一个windows服务应用程序,
并且在安装过程中将该服务的属性“允许服务与桌面交互”设置为true。有思路的同志请尽量说详细点,
因为我很初级,很可能不知道对您的思路该如何开始。谢谢。
并且在安装过程中将该服务的属性“允许服务与桌面交互”设置为true。有思路的同志请尽量说详细点,
因为我很初级,很可能不知道对您的思路该如何开始。谢谢。
解决方案 »
- 双击一个控件弹出一个新的Form,如何在新的Form中获取前一个Form中触发它的控件
- 如何获取选中tabpage中的控件信息
- 怎样转换日期,一句代码。
- 怎么样实现DataGridView的cell中内容出现错误后,自动重新恢复到编辑状态!
- 50分,帮忙改个SQL语句
- 如何通过Winform窗体向XML中写入数据?
- 能不能对一个对象进行某个操做后,以后在多线程时,在任何地方对这个对象的任何属性的写操做就变成同步的。
- 在WinForm中Client的命名空间是什么?
- 怎样清空RadioButtonList和CheckBox中的选项?
- StreamReader读中文文件,出现乱码,哪位大峡帮忙一下,谢谢
- 如何用用c#访问word文档??
- 一个简单问题:我想要在两个Form之间传递数据,该怎样定义变量呢?
OpenService
ChangeServiceConfig
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);
[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只读。