赞
踩
string source = "DemoSourceWithinApplicationLog";//写exe名称即可,容易识别
string log = "Application";
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, log);//没找到先注册
}
EventLog.WriteEntry(source, "This is a warning from the demo log",
EventLogEntryType.Warning);
需要注意的是运行程序需要以admin运行,否则没有权限读取event log的注册表
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。