鹿我所录的博客

记录我在学习C#中的点点滴滴,记录下以备后来人借鉴。

 

01 2014 档案

C# windows服务:如何检测指定的Windows服务是否启动
摘要:public void CheckServerState(string ServiceName) { ServiceController[] service = ServiceController.GetServices(); bool isStart = false; bool isExite = false; for (int i = 0; i < service.Length; i++) { if (service[i]... 阅读全文

posted @ 2014-01-21 01:07 鹿我所录 阅读(6227) 评论(0) 推荐(1) 编辑

C# windows服务:C#windows服务中的Timer控件的使用
摘要:C# windows服务程序中的Timer控件的使用问题是如何解决的呢?今天和同事一起研究了下C# windows服务程序中的Timer控件的使用的写法.我们在建立一个C# windows服务程序后,要用到计时器的话一般都会想到Timer控件,于是到工具器把Timer控件拉过来,双击写事件,设置时间,哇,成功了....但服务一跑起来,唉,怎么回事,时间到了怎么没有执行事件呢?后来,我找很多资料才知道,这个Timer控件是winForm下的,不能用在C# windows服务程序中.怎么办呢.......打开"工具箱"---右键---"选择项"---找到Ti 阅读全文

posted @ 2014-01-13 15:37 鹿我所录 阅读(627) 评论(0) 推荐(0) 编辑

C# windows服务:创建Windows服务(Windows Services)的一般步骤
摘要:C#创建Windows服务(Windows Services)Windows服务在Visual Studio 以前的版本中叫NT服务,在VS.net启用了新的名称。用Visual C# 创建Windows服务不是一件困难的事,本文就将指导你一步一步创建一个Windows服务并使用它。这个服务在启动和停止时,向一个文本文件中写入一些文字信息。C#创建Windows服务第一步:创建服务框架要创建一个新的 Windows 服务,可以从Visual C# 工程中选取 Windows 服务(Windows Service)选项,给工程一个新文件名,然后点击 确定。你可以看到,向导向工程文件中增加WebS 阅读全文

posted @ 2014-01-13 15:29 鹿我所录 阅读(737) 评论(0) 推荐(0) 编辑

C# windows服务:通过cmd命令安装、卸载、启动和停止Windows Service(InstallUtil.exe)
摘要:步骤:1。运行--〉cmd:打开cmd命令框2。在命令行里定位到InstallUtil.exe所在的位置InstallUtil.exe 默认的安装位置是在C:/Windows/Microsoft.NET/Framework/v2.0.50727里面,所以你要在cmd里通过cd定位到该位置(cd C:/Windows/Microsoft.NET/Framework/v2.0.50727)3。操作命令:1). 安装服务命令:在命令行里输入下面的命令:InstallUtil.exe Path/WinServiceName.exe其中Path表示ServiceName.exe所在的位置,回车即可2). 阅读全文

posted @ 2014-01-13 15:25 鹿我所录 阅读(17902) 评论(2) 推荐(3) 编辑

C# Winform添加全局快捷键(老板键)
摘要:using System;using System.Collections.Generic;using System.Runtime.InteropServices;using System.Windows.Forms;namespace drmaple{ class HotKey { //如果函数执行成功,返回值不为0。 //如果函数执行失败,返回值为0。要得到扩展错误信息,调用GetLastError。 [DllImport("user32.dll", SetLastError = true)] public static... 阅读全文

posted @ 2014-01-07 21:42 鹿我所录 阅读(3107) 评论(0) 推荐(2) 编辑

C#中Graphics的画图代码【转】
摘要:我要写多几个字上去string str = "Baidu"; //写什么字?Font font = Font("宋体",30f); //字是什么样子的?Brush brush = Brushes.Red; //用红色涂上我的字吧;PointF point = new PointF(10f,10f); //从什么地方开始写字捏? //横着写还是竖着写呢?System.Drawing.StringFormat sf = new System.Drawing.StringFormat();//还是竖着写吧sf.FormatFlags = StringForma 阅读全文

posted @ 2014-01-04 14:31 鹿我所录 阅读(19007) 评论(0) 推荐(0) 编辑

C# 如何获取屏幕的截图,以及如何在图像上添加文字
摘要:关键代码为 Screen sc = Screen.PrimaryScreen; Rectangle rct = sc.Bounds; Image img = new Bitmap(rct.Width, rct.Height); Graphics gp = Graphics.FromImage(img); gp.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(rct.Width, rct.Height)); ... 阅读全文

posted @ 2014-01-04 14:09 鹿我所录 阅读(1506) 评论(0) 推荐(0) 编辑

C# 如何获取鼠标在屏幕上的位置,不论程序是否为活动状态
摘要:一开始我认为应该使用HOOK来写,而且必须使用全局HOOK,结果在一次偶然的机会得到,原来其实根本没有那个必要。直接上代码吧,一看就明白 Point ms = Control.MousePosition; this.label2.Text = string.Format("{0}:{1}", ms.X, ms.Y); MouseButtons mb= Control.MouseButtons; if (mb == System.Windows.Forms.MouseButtons.Left) this.l... 阅读全文

posted @ 2014-01-04 14:07 鹿我所录 阅读(8301) 评论(0) 推荐(0) 编辑

C#中List〈string〉和string[]数组之间的相互转换
摘要:1,从System.String[]转到ListSystem.String[] str={"str","string","abc"};List listS=new List(str);2, 从List转到System.String[]List listS=new List();listS.Add("str");listS.Add("hello");System.String[] str=listS.ToArray();详细出处参考:http://www.jb51.net/article/3239 阅读全文

posted @ 2014-01-02 20:08 鹿我所录 阅读(283) 评论(0) 推荐(0) 编辑

导航

统计

点击右上角即可分享
微信分享提示