获取window服务路径
来源:互联网 发布:c语言流程图生成器 编辑:程序博客网 时间:2024/03/29 07:57
static public void WriteLog(string strLog) { //string sFilePath = "d:\\hsx\\" + DateTime.Now.ToString("yyyyMM"); string sFilePath = FilePath("RestartServiceServer") + "\\日志" + DateTime.Now.ToString("yyyyMM"); string sFileName = "errLog" + DateTime.Now.ToString("dd") + ".log"; sFileName = sFilePath + "\\" + sFileName; //文件的绝对路径 if (!Directory.Exists(sFilePath))//验证路径是否存在 { Directory.CreateDirectory(sFilePath);//不存在则创建 } FileStream fs; StreamWriter sw; if (File.Exists(sFileName))//验证文件是否存在,有则追加,无则创建 { fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write); } else { fs = new FileStream(sFileName, FileMode.Create, FileAccess.Write); } sw = new StreamWriter(fs); sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " --- " + strLog); sw.Close(); fs.Close(); } static public string FilePath(string serviceName) { RegistryKey _Key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\" + serviceName); if (_Key != null) { object _ObjPath = _Key.GetValue("ImagePath"); if (_ObjPath != null) { string strPath = _ObjPath.ToString(); return strPath.Substring(0, strPath.LastIndexOf('\\')); } } return ""; }
0 0
- 获取window服务路径
- 获取Windows服务安装路径
- windows服务获取其路径
- Window获取当前目录路径心得
- C#获取WIN服务的路径和安装卸载服务
- Window下获取执行文件的目录的路径函数
- java web项目获取window/linux真实路径
- window 服务
- Window服务
- window服务
- window服务
- window 服务
- Window服务
- window服务
- Window服务
- 获取 window
- .NET中windows服务如何获取自己的安装路径
- c# windows服务如何获取自己的安装路径
- sizeof的详尽计算结构体字节数方法
- ios 图片处理
- 服务器jsp推送
- [后缀数组+二分+rmq] hdu 5008 Boring String Problem
- WF-Mailer Fails to Send Email Notifications after cloning
- 获取window服务路径
- 【工具】MQ常用命令
- 关于spring中HibernateTransactionManager和DataSourceTransactionManager
- [GEiv]第五章:个体集群 虚假的分配与释放
- 使用gcd_ wait来 处理gcd
- Netty的几个要点
- 花生壳内网穿透、nat123映射p2p穿透,都是如何穿透的
- MySQL函数
- 一个简单的键盘钩子程序