标签:send .so tee try src 搜索 知识 oid 图片
实现效果:

知识运用:
EventLog类的SourceExists CreateEventSource方法
public static bool SourceExists (string source) //在计算机的注册表中搜索给定的事件源
public static void CreateEventLogSource (string source , string logName ) //建立一个能够将事件信息写入到系统的特定日志中的应用程序
Source属性 WriteEntry方法
public string Source {get ;set; } //获取或设置在写入事件日志时要注册和使用的源名称
public void WriteEntry (string message) //用来将项写入事件日志
实现代码:
private void button1_Click(object sender, EventArgs e)
{
if (!EventLog.SourceExists(textBox2.Text)) //判断是否存在相同的日志
{
EventLog.CreateEventSource(textBox2.Text,textBox1.Text); //创建日志
}
EventLog eventlog = new EventLog(); //创建日志对象
eventlog.Source = textBox2.Text; //指定日志来源
eventlog.WriteEntry(textBox3.Text); //写入日志信息
}
标签:send .so tee try src 搜索 知识 oid 图片
原文地址:https://www.cnblogs.com/feiyucha/p/10300608.html