diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-04 20:29:53 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-04 20:29:53 +0100 |
commit | ac2d760ef5ee6726bfa480e1860a63c48701f52c (patch) | |
tree | 66cd8386b773b334c92fc6304eab68fe026aa3b1 /docs/log/EventView.aspx.html | |
parent | 454bf34c5879d2755b0ebc1b54d49330a7d99a07 (diff) | |
download | wolfbones-ac2d760ef5ee6726bfa480e1860a63c48701f52c.tar.gz wolfbones-ac2d760ef5ee6726bfa480e1860a63c48701f52c.tar.bz2 |
added SID artive for event logging
Diffstat (limited to 'docs/log/EventView.aspx.html')
-rw-r--r-- | docs/log/EventView.aspx.html | 1156 |
1 files changed, 1156 insertions, 0 deletions
diff --git a/docs/log/EventView.aspx.html b/docs/log/EventView.aspx.html new file mode 100644 index 0000000..01b213e --- /dev/null +++ b/docs/log/EventView.aspx.html @@ -0,0 +1,1156 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html><head> + + + + + + <title>CodeProject: Adding User Name to Events. Free source code and programming help</title> + +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<meta name="Description" content="How to add user names to the Event Viewer.; Author: maththaios; Section: Win32/64 SDK & OS; Chapter: Platforms, Frameworks & Libraries"> +<meta name="Keywords" content="VC6, WinXP, VS6, Dev, Intermediate,Win32/64 SDK & OS,Platforms, Frameworks & Libraries,Free source code, tutorials"> +<meta name="Author" content="The Code Project"> +<meta name="Rating" content="General"> +<meta name="Robots" content="index, follow"> +<meta name="Revisit-After" content="1 days"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - All topics" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=1"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - MFC / C++" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=2"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - C#" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=3"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - ASP.NET" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=4"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - .NET" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=5"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Latest articles - VB.NET" href="http://www.codeproject.com/webservices/articlerss.aspx?cat=6"> +<link rel="alternate" type="application/rss+xml" title="CodeProject Lounge Postings" href="http://www.codeproject.com/webservices/LoungeRSS.aspx"> +<link rel="search" type="application/opensearchdescription+xml" title="CodeProject" href="http://www.codeproject.com/info/OpenSearch.xml"> + <!-- base --> + +<script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); +</script><script src="EventView.aspx_files/ga.js" type="text/javascript"></script> +<script type="text/javascript"> + var pageTracker = _gat._getTracker("UA-1735123-1"); + pageTracker._setDomainName("www.codeproject.com"); + pageTracker._setSessionTimeout("1200"); // 20 mins + pageTracker._initData(); + pageTracker._trackPageview(); +</script> + + <script type="text/javascript" language="Javascript">//<![CDATA[ +if(top!=self)top.location.href=location.href; if(typeof(DemoUrl)!="undefined")document.write(unescape('%3Cme')+'ta http'+'-equiv="re' +'fresh" con'+'tent="1;url='+DemoUrl+unescape('"%3CE')); +//]]></script> + +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/oncopy.js"></script> +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/JobsSummaryRetriever.js"></script> +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/jquery-1.js"></script> +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/addto.js"></script> +<script type="text/javascript" language="Javascript">//<![CDATA[ +function ToggleMenu(itemName) +{ + var elm = document.getElementById(itemName); + var i,others = document.getElementById('SectionMenu'); + for(i=0; i < others.childNodes.length; i++) + { + var other = others.childNodes[i]; + if ((other.className == 'MenuSectionBlock') && (other != elm)) + other.style.display='none'; + } + if (elm.style.display == 'block') elm.style.display='none'; + else elm.style.display='block'; + return false; +} + +//]]></script> + +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/rateitem.js"></script> +<script type="text/javascript" language="Javascript">//<![CDATA[ +function ChkRt(val) { if (val<=2) {$('#RateComDiv').css("display","");}else $('#RateComDiv').css("display","none");} +//]]></script> + +<script type="text/javascript" language="Javascript">//<![CDATA[ +var Selected = "-1"; + +function SwitchMessage(e, msgId) +{ + if (!msgId) { + if(!e)e=window.event; + var target=e.target?e.target:e.srcElement; + while(target&&target.id!='DynMessLink')target=target.parentNode; + if(!target||target.id!='DynMessLink')return; + msgId=target.name; + } + if(Selected&&Selected!=""){ + var body=eval("document.getElementById('F" + Selected + "_h1')"); + if(body) body.style.display = 'none'; + var head=eval("document.getElementById('F" + Selected + "_h0')"); + if(head) head.className = head.className.replace("Sel", "UnSel"); + } + if(Selected==msgId.toString()) + Selected=""; + else { + Selected=msgId.toString(); + var body=eval("document.getElementById('F" + Selected + "_h1')"); + if(body){ + if(body.style.display=='none') body.style.display=''; + else body.style.display = 'none'; + } + var head=eval("document.getElementById('F" + Selected + "_h0')"); + if (head) + head.className = head.className.replace("UnSel", "Sel"); + if(body&&head&&body.style.display!='none'){ + document.body.scrollTop = getRealPos(head, "Top") - document.body.clientHeight/10; + EnsureMessageVisible(Selected, true); + } + } + if (e){if(e.preventDefault)e.preventDefault;else e.returnValue=false;} + return false; +} + +//]]></script> + +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/ShortCuts.js"></script> +<link type="text/css" rel="stylesheet" href="EventView.aspx_files/CodeProject.css"> +<link type="text/css" rel="stylesheet" href="EventView.aspx_files/ForumClassic.css"> +<link type="text/css" rel="stylesheet" href="EventView.aspx_files/navmenu.css"> +<link rel="icon" href="http://www.codeproject.com/favicon.ico" type="image/ico"> +<link rel="shortcut icon" href="http://www.codeproject.com/favicon.ico" type="image/ico"> + +</head><body> + +<a href="#Main"><img alt="Click here to Skip to main content" src="EventView.aspx_files/t_002.gif" style="border-style: none; position: absolute; top: 0pt; left: 0pt; width: 1px; height: 1px; z-index: 100;"></a> + +<div style="margin: 0px; padding: 0px; width: 100%;"> + <div style="width: 100%;"> + +<table class="MemberNavBar" width="100%" cellpadding="5" cellspacing="0"> +<tbody><tr> +<td style="font-weight: bold;">5,943,977 members and growing! (16,903 online)</td> +<td align="right"> + + + +<div id="ctl00_MemberMenu_LoggedOffOptions" class="MemberNavBarText" style="margin: 0pt; padding: 0pt;"> + <a name="SignUp"></a> +<form name="subForm" id="subForm" action="/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick" method="post" style="margin: 0pt; padding: 0pt;"> +Email <input class="SmallText" name="Email" id="Email" style="width: 100px;" type="text"> +Password <input class="SmallText" name="Password" id="Password" style="width: 60px;" type="password"> +<input value="Sign in" class="FormButton" type="submit"> +<script type="text/javascript"> +function Join(){document.location.href='/script/Membership/Modify.aspx';return false;} +document.write('<input type="button" class="FormButton" onclick="return Join();" value="Join"'); +document.write('<input type="hidden" name="fld_quicksign" value="true" />'); +</script><input class="FormButton" onclick="return Join();" value="Join" type="button"><input name="fld_quicksign" value="true" type="hidden"> +<input checked="checked" name="cookie" id="RememberMeCheck" type="checkbox"> +<label for="RememberMeCheck">Remember me?</label> +<a id="ctl00_MemberMenu_SendPassword" href="http://www.codeproject.com/script/Membership/SendPassword.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick"><img alt="help" src="EventView.aspx_files/help.gif" width="16" align="middle" border="0" height="16">Lost your password?</a> +</form> + +</div> + +</td> +</tr> +</tbody></table></div> + <table width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr> + <td class="HeaderLogo"><a href="http://www.codeproject.com/"><img id="ctl00_Logo" src="EventView.aspx_files/logo225x90.gif" alt="The Code Project" style="border-width: 0px; height: 90px; width: 225px;"></a></td> + <td class="HeaderBanner" width="100%" align="right"><iframe src="EventView.aspx_files/ServeHTML.html" scrolling="no" width="728" frameborder="0" height="90"></iframe></td> + </tr></tbody></table> + + + + + + + +<div class="NavBarMain"> +<ul id="nav"> +<li><a href="http://www.codeproject.com/">Home</a></li> +<li><a class="down" href="http://www.codeproject.com/script/articles/latest.aspx">Articles</a> + + <ul class="flyout"> + <li><a class="fly" href="http://www.codeproject.com/script/articles/latest.aspx">Latest</a></li> + <li><a class="fly" href="http://www.codeproject.com/info/search.aspx">Search</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/articles/TopArticles.aspx">Most Popular</a></li> + <li><a class="fly" href="http://www.codeproject.com/info/search.aspx?vidlst=152&sa_us=True">Beginner Articles</a></li> + + <li><a class="fly" href="http://www.codeproject.com/script/Content/SiteMap.aspx">Topic List</a></li> + <li><a class="fly" href="http://www.codeproject.com/info/submit.aspx">Submit an Article</a></li> + <li><a class="fly" href="http://www.codeproject.com/info/submit.aspx#Update">Update an Article</a></li> + <li><a class="last" href="http://www.codeproject.com/script/awards/CurrentCompetitions.aspx">Article Competition</a></li> + </ul> + +</li> +<li><a class="down" href="http://www.codeproject.com/script/Forums/List.aspx">Message Boards</a> + + <ul class="flyout"> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=12076">ASP.NET</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=4486">ATL / WTL / STL</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1647">C++ / MFC</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=3785">(Managed) C++/CLI</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1649">C#</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1648">COM</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=186301">Hardware</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1004117">LINQ and .NET 3.5</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1650">.NET Framework</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1644">OS / SysAdmin</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1004257">Silverlight</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1725">General Database</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1646">VB.NET</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1640">Web Development</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1004114">WPF / WCF / WF</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=3421">XML / XSL</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1642">General Discussions</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/View.aspx?fid=1645">Suggestions / Site Bugs</a></li> + + <li><a class="last" href="http://www.codeproject.com/script/Forums/List.aspx">All Message Boards...</a></li> + </ul> + +</li> + +<li><a href="http://www.codeproject.com/script/Jobs/">Job Board</a></li> + + +<li><a href="http://www.codeproject.com/script/Catalog/">Component Catalog</a></li> + + +<li><a href="http://www.codeproject.com/info/faq.aspx">Help!</a> + + <ul class="flyout"> + <li><a class="fly" href="http://www.codeproject.com/info/Guide.aspx">What is 'The Code Project'?</a></li> + <li><a class="fly" href="http://www.codeproject.com/info/faq.aspx">General FAQ</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Forums/List.aspx">Post a Question</a></li> + <li><a class="fly" href="http://www.codeproject.com/script/Content/SiteMap.aspx">Site Directory</a></li> + <li><a class="last" href="http://www.codeproject.com/info/about.aspx">About Us</a></li> + </ul> + +</li> + +<li style="float: right;"><a href="http://www.codeproject.com/Lounge.aspx">Lounge</a></li> +</ul> + +</div> + + + <div style="width: 100%;"><a name="_top"></a><table id="ctl00_ArticleTopHeader_HeaderTable" class="ArticleHeader" width="100%" cellpadding="3"> + <tbody><tr valign="top"> + <td class="SmallText"> + <a id="ctl00_ArticleTopHeader_ChapterLink" href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=8">Platforms, Frameworks & Libraries</a> » + <a id="ctl00_ArticleTopHeader_SectionLink" href="http://www.codeproject.com/KB/winsdk/">Win32/64 SDK & OS</a> » + <a id="ctl00_ArticleTopHeader_SubsectionLink" href="http://www.codeproject.com/KB/winsdk/index.aspx?#Win32/64%20SDK%20&%20OS%20-%20General">General</a> + <span id="ctl00_ArticleTopHeader_SkillLevel" class="ArticleIntermediate"> Intermediate</span> + <span id="ctl00_ArticleTopHeader_LicenceTerms"></span> + <br><br> + <h1><span id="ctl00_ArticleTopHeader_ArticleTitle" class="ArticleTopTitle">Adding User Name to Events</span></h1> + <b>By <a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=661994">maththaios</a></b><br> + + <br> + <span id="ctl00_ArticleTopHeader_ArticleDescr">How to add user names to the Event Viewer.</span> +</td> + <td style="width: 210px;"> + <span id="ctl00_ArticleTopHeader_ArticleAttributes" class="SmallText">VC6, C++Windows, WinXPVS6, Visual Studio, Dev</span> + <table style="margin: 8px 0pt 0pt; padding: 0pt;" class="SmallText"> + + <tbody><tr><td>Posted:</td><td><b>22 Feb 2006</b></td></tr> + + <tr><td>Views:</td><td><b>16,430</b></td></tr> + + <tr><td>Bookmarked:</td><td><b>14 times</b></td></tr> + + + + + </tbody></table> +</td> + </tr> +</tbody></table> + + </div> +</div> + +<div> + +<div id="ctl00_LHNavBar" class="LHNavBar"> + + + +<div class="FeatureBlockHeader" style="border-style: none; margin-top: 5px;">Announcements</div> +<div class="FeatureBlockContent" style="border-style: none; padding: 0pt; margin-bottom: 5px;"> +<table cellpadding="2"> + + + + + + + + +<tbody><tr valign="middle"><td><img src="EventView.aspx_files/javaduke.jpg" alt="Comp" width="24" height="24"></td> +<td><a href="http://www.codeproject.com/Contests/Java/">Java Competition</a></td></tr> + + + +<tr valign="middle"><td><img src="EventView.aspx_files/smartclient24.jpg" alt="Comp" width="24" align="middle" height="24"></td> +<td><a href="http://www.codeproject.com/Contests/SmartClient/">Smart Client Comp</a></td></tr> + + + +<tr valign="middle"><td><img src="EventView.aspx_files/LAMP.GIF" alt="Comp" width="24" align="middle" height="24"></td> +<td><a href="http://www.codeproject.com/Contests/LAMP/">LAMP drag-bike comp</a></td></tr> + + + +<tr valign="middle"><td><img src="EventView.aspx_files/MonthlyComp.png" alt="Comp" width="24" align="middle" height="24"></td> +<td><a id="ctl00_Announcements_CompLink" href="http://www.codeproject.com/Feature/ArticleCompetition/">Monthly Competition</a></td></tr> +</tbody></table> +</div> + + +<div id="Th"> + +<div class="FeatureBlockHeader" style="margin-top: 7px;">Want a new Job?</div> +<div class="FeatureBlockContent"> + + +<ul class="InfoList"> + + <li> + <a id="RelatedJobs_RC_ctl00_Lnk" href="http://www.codeproject.com/script/Jobs/View.aspx?jid=540">Would you like to work at The Code Project? (ASP.NET, C#, SQL)</a> + at The Code Project + in Canada + </li> + + <li> + <a id="RelatedJobs_RC_ctl01_Lnk" href="http://www.codeproject.com/script/Jobs/View.aspx?jid=544">Epic Inpatient Project Manager</a> + at Parker HealthcareIT + in United States + </li> + + <li> + <a id="RelatedJobs_RC_ctl02_Lnk" href="http://www.codeproject.com/script/Jobs/View.aspx?jid=558">SharePoint Developer</a> + at INTEQNA + in Canada + </li> + +<li> + <a id="RelatedJobs_LJ" href="http://www.codeproject.com/script/Jobs/List.aspx">View Latest Jobs...</a> +</li> +</ul> + +</div> +</div> + + + + <div id="SectionMenu"> +<div class="MenuCat">Chapters</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=1" onclick="return ToggleMenu('Chapter1');">Desktop Development</a></div> +<div class="MenuSectionBlock" id="Chapter1" style="display: none;"> +<div class="MI" id="Section1"><a href="http://www.codeproject.com/KB/buttons/">Button Controls</a></div> +<div class="MI" id="Section15"><a href="http://www.codeproject.com/KB/clipboard/">Clipboard</a></div> +<div class="MI" id="Section2"><a href="http://www.codeproject.com/KB/combobox/">Combo & List Boxes</a></div> +<div class="MI" id="Section67"><a href="http://www.codeproject.com/KB/dialog/">Dialogs and Windows</a></div> +<div class="MI" id="Section107"><a href="http://www.codeproject.com/KB/gadgets/">Desktop Gadgets</a></div> +<div class="MI" id="Section16"><a href="http://www.codeproject.com/KB/docview/">Document / View</a></div> +<div class="MI" id="Section4"><a href="http://www.codeproject.com/KB/edit/">Edit Controls</a></div> +<div class="MI" id="Section17"><a href="http://www.codeproject.com/KB/files/">Files and Folders</a></div> +<div class="MI" id="Section3"><a href="http://www.codeproject.com/KB/grid/">Grid & Data Controls</a></div> +<div class="MI" id="Section5"><a href="http://www.codeproject.com/KB/list/">List Controls</a></div> +<div class="MI" id="Section6"><a href="http://www.codeproject.com/KB/menus/">Menus</a></div> +<div class="MI" id="Section14"><a href="http://www.codeproject.com/KB/miscctrl/">Miscellaneous</a></div> +<div class="MI" id="Section18"><a href="http://www.codeproject.com/KB/printing/">Printing</a></div> +<div class="MI" id="Section95"><a href="http://www.codeproject.com/KB/progress/">Progress Controls</a></div> +<div class="MI" id="Section11"><a href="http://www.codeproject.com/KB/selection/">Selection Controls</a></div> +<div class="MI" id="Section19"><a href="http://www.codeproject.com/KB/shell/">Shell and IE programming</a></div> +<div class="MI" id="Section68"><a href="http://www.codeproject.com/KB/smart/">Smart Client</a></div> +<div class="MI" id="Section8"><a href="http://www.codeproject.com/KB/splitter/">Splitter Windows</a></div> +<div class="MI" id="Section9"><a href="http://www.codeproject.com/KB/static/">Static & Panel Controls</a></div> +<div class="MI" id="Section10"><a href="http://www.codeproject.com/KB/statusbar/">Status Bar</a></div> +<div class="MI" id="Section7"><a href="http://www.codeproject.com/KB/tabs/">Tabs & Property Pages</a></div> +<div class="MI" id="Section12"><a href="http://www.codeproject.com/KB/toolbars/">Toolbars & Docking windows</a></div> +<div class="MI" id="Section13"><a href="http://www.codeproject.com/KB/tree/">Tree Controls</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=2" onclick="return ToggleMenu('Chapter2');">Web Development</a></div> +<div class="MenuSectionBlock" id="Chapter2" style="display: none;"> +<div class="MI" id="Section70"><a href="http://www.codeproject.com/KB/ajax/">Ajax and Atlas</a></div> +<div class="MI" id="Section27"><a href="http://www.codeproject.com/KB/applications/">Applications & Tools</a></div> +<div class="MI" id="Section85"><a href="http://www.codeproject.com/KB/asp/">ASP</a></div> +<div class="MI" id="Section89"><a href="http://www.codeproject.com/KB/aspnet/">ASP.NET</a></div> +<div class="MI" id="Section28"><a href="http://www.codeproject.com/KB/webforms/">ASP.NET Controls</a></div> +<div class="MI" id="Section38"><a href="http://www.codeproject.com/KB/ATL-Server/">ATL Server</a></div> +<div class="MI" id="Section29"><a href="http://www.codeproject.com/KB/web-cache/">Caching</a></div> +<div class="MI" id="Section91"><a href="http://www.codeproject.com/KB/web-image/">Charts, Graphs and Images</a></div> +<div class="MI" id="Section25"><a href="http://www.codeproject.com/KB/scripting/">Client side scripting</a></div> +<div class="MI" id="Section30"><a href="http://www.codeproject.com/KB/custom-controls/">Custom Controls</a></div> +<div class="MI" id="Section23"><a href="http://www.codeproject.com/KB/HTML/">HTML / CSS</a></div> +<div class="MI" id="Section24"><a href="http://www.codeproject.com/KB/ISAPI/">ISAPI</a></div> +<div class="MI" id="Section33"><a href="http://www.codeproject.com/KB/server-management/">Site & Server Management</a></div> +<div class="MI" id="Section34"><a href="http://www.codeproject.com/KB/session/">Session State</a></div> +<div class="MI" id="Section113"><a href="http://www.codeproject.com/KB/silverlight/">Silverlight</a></div> +<div class="MI" id="Section36"><a href="http://www.codeproject.com/KB/trace/">Trace and Logs</a></div> +<div class="MI" id="Section31"><a href="http://www.codeproject.com/KB/user-controls/">User Controls</a></div> +<div class="MI" id="Section37"><a href="http://www.codeproject.com/KB/validation/">Validation</a></div> +<div class="MI" id="Section35"><a href="http://www.codeproject.com/KB/viewstate/">View State</a></div> +<div class="MI" id="Section26"><a href="http://www.codeproject.com/KB/WAP/">WAP / WML</a></div> +<div class="MI" id="Section32"><a href="http://www.codeproject.com/KB/web-security/">Web Security</a></div> +<div class="MI" id="Section20"><a href="http://www.codeproject.com/KB/webservices/">Web Services</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=9" onclick="return ToggleMenu('Chapter9');">Enterprise Systems</a></div> +<div class="MenuSectionBlock" id="Chapter9" style="display: none;"> +<div class="MI" id="Section98"><a href="http://www.codeproject.com/KB/MCMS/">Content Management Server</a></div> +<div class="MI" id="Section99"><a href="http://www.codeproject.com/KB/biztalk/">Microsoft BizTalk Server</a></div> +<div class="MI" id="Section102"><a href="http://www.codeproject.com/KB/exchange/">Microsoft Exchange</a></div> +<div class="MI" id="Section90"><a href="http://www.codeproject.com/KB/office/">Office Development</a></div> +<div class="MI" id="Section101"><a href="http://www.codeproject.com/KB/sharepoint/">SharePoint Server</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=3" onclick="return ToggleMenu('Chapter3');">Multimedia</a></div> +<div class="MenuSectionBlock" id="Chapter3" style="display: none;"> +<div class="MI" id="Section42"><a href="http://www.codeproject.com/KB/audio-video/">Audio and Video</a></div> +<div class="MI" id="Section44"><a href="http://www.codeproject.com/KB/directx/">DirectX</a></div> +<div class="MI" id="Section46"><a href="http://www.codeproject.com/KB/GDI/">GDI</a></div> +<div class="MI" id="Section47"><a href="http://www.codeproject.com/KB/GDI-plus/">GDI+</a></div> +<div class="MI" id="Section43"><a href="http://www.codeproject.com/KB/graphics/">General Graphics</a></div> +<div class="MI" id="Section45"><a href="http://www.codeproject.com/KB/openGL/">OpenGL</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=4" onclick="return ToggleMenu('Chapter4');">Database</a></div> +<div class="MenuSectionBlock" id="Chapter4" style="display: none;"> +<div class="MI" id="Section66"><a href="http://www.codeproject.com/KB/database/">Database</a></div> +<div class="MI" id="Section100"><a href="http://www.codeproject.com/KB/reporting-services/">SQL Reporting Services</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=8" onclick="return ToggleMenu('Chapter8');">Platforms, Frameworks & Libraries</a></div> +<div class="MenuSectionBlock" id="Chapter8"> +<div class="MI" id="Section83"><a href="http://www.codeproject.com/KB/atl/">ATL</a></div> +<div class="MI" id="Section117"><a href="http://www.codeproject.com/KB/MFC/">MFC</a></div> +<div class="MI" id="Section88"><a href="http://www.codeproject.com/KB/stl/">STL</a></div> +<div class="MI" id="Section84"><a href="http://www.codeproject.com/KB/wtl/">WTL</a></div> +<div class="MI" id="Section49"><a href="http://www.codeproject.com/KB/COM/">COM / COM+</a></div> +<div class="MI" id="Section76"><a href="http://www.codeproject.com/KB/dotnet/">.NET Framework</a></div> +<div class="MIS" id="Section92"><a href="http://www.codeproject.com/KB/winsdk/">Win32/64 SDK & OS</a></div> +<div class="MI" id="Section108"><a href="http://www.codeproject.com/KB/vista/">Vista API</a></div> +<div class="MI" id="Section110"><a href="http://www.codeproject.com/KB/vista-security/">Vista Security</a></div> +<div class="MI" id="Section82"><a href="http://www.codeproject.com/KB/cross-platform/">Cross Platform</a></div> +<div class="MI" id="Section69"><a href="http://www.codeproject.com/KB/game/">Game Development</a></div> +<div class="MI" id="Section73"><a href="http://www.codeproject.com/KB/mobile/">Mobile Development</a></div> +<div class="MI" id="Section106"><a href="http://www.codeproject.com/KB/WC/">Windows CardSpace</a></div> +<div class="MI" id="Section103"><a href="http://www.codeproject.com/KB/WCF/">Windows Communication Foundation</a></div> +<div class="MI" id="Section104"><a href="http://www.codeproject.com/KB/WPF/">Windows Presentation Foundation</a></div> +<div class="MI" id="Section105"><a href="http://www.codeproject.com/KB/WF/">Windows Workflow Foundation</a></div> +<div class="MI" id="Section119"><a href="http://www.codeproject.com/KB/library/">Libraries</a></div> +<div class="MI" id="Section122"><a href="http://www.codeproject.com/KB/powershell/">Windows Powershell</a></div> +<div class="MI" id="Section123"><a href="http://www.codeproject.com/KB/linq/">LINQ</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=5" onclick="return ToggleMenu('Chapter5');">Languages</a></div> +<div class="MenuSectionBlock" id="Chapter5" style="display: none;"> +<div class="MI" id="Section71"><a href="http://www.codeproject.com/KB/cpp/">C / C++ Language</a></div> +<div class="MI" id="Section72"><a href="http://www.codeproject.com/KB/mcpp/">C++ / CLI</a></div> +<div class="MI" id="Section93"><a href="http://www.codeproject.com/KB/cs/">C#</a></div> +<div class="MI" id="Section78"><a href="http://www.codeproject.com/KB/msil/">MSIL</a></div> +<div class="MI" id="Section86"><a href="http://www.codeproject.com/KB/vbscript/">VBScript</a></div> +<div class="MI" id="Section87"><a href="http://www.codeproject.com/KB/vb/">VB.NET</a></div> +<div class="MI" id="Section115"><a href="http://www.codeproject.com/KB/vb-interop/">VB6 Interop</a></div> +<div class="MI" id="Section77"><a href="http://www.codeproject.com/KB/net-languages/">Other .NET Languages</a></div> +<div class="MI" id="Section21"><a href="http://www.codeproject.com/KB/XML/">XML</a></div> +<div class="MI" id="Section96"><a href="http://www.codeproject.com/KB/java/">Java</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=6" onclick="return ToggleMenu('Chapter6');">General Programming</a></div> +<div class="MenuSectionBlock" id="Chapter6" style="display: none;"> +<div class="MI" id="Section57"><a href="http://www.codeproject.com/KB/recipes/">Algorithms & Recipes</a></div> +<div class="MI" id="Section64"><a href="http://www.codeproject.com/KB/bugs/">Bugs & Workarounds</a></div> +<div class="MI" id="Section79"><a href="http://www.codeproject.com/KB/collections/">Collections</a></div> +<div class="MI" id="Section56"><a href="http://www.codeproject.com/KB/security/">Cryptography & Security</a></div> +<div class="MI" id="Section50"><a href="http://www.codeproject.com/KB/datetime/">Date and Time</a></div> +<div class="MI" id="Section52"><a href="http://www.codeproject.com/KB/DLL/">DLLs & Assemblies</a></div> +<div class="MI" id="Section80"><a href="http://www.codeproject.com/KB/exception/">Exception Handling</a></div> +<div class="MI" id="Section81"><a href="http://www.codeproject.com/KB/locale/">Localisation</a></div> +<div class="MI" id="Section53"><a href="http://www.codeproject.com/KB/macros/">Macros and Add-ins</a></div> +<div class="MI" id="Section54"><a href="http://www.codeproject.com/KB/tips/">Programming Tips</a></div> +<div class="MI" id="Section55"><a href="http://www.codeproject.com/KB/string/">String handling</a></div> +<div class="MI" id="Section22"><a href="http://www.codeproject.com/KB/IP/">Internet / Network</a></div> +<div class="MI" id="Section58"><a href="http://www.codeproject.com/KB/threads/">Threads, Processes & IPC</a></div> +<div class="MI" id="Section59"><a href="http://www.codeproject.com/KB/winhelp/">WinHelp / HTMLHelp</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=10" onclick="return ToggleMenu('Chapter10');">Graphics / Design</a></div> +<div class="MenuSectionBlock" id="Chapter10" style="display: none;"> +<div class="MI" id="Section40"><a href="http://www.codeproject.com/KB/expression/">Expression</a></div> +<div class="MI" id="Section114"><a href="http://www.codeproject.com/KB/usability/">Usability</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=11" onclick="return ToggleMenu('Chapter11');">Development Lifecycle</a></div> +<div class="MenuSectionBlock" id="Chapter11" style="display: none;"> +<div class="MI" id="Section51"><a href="http://www.codeproject.com/KB/debug/">Debug Tips</a></div> +<div class="MI" id="Section39"><a href="http://www.codeproject.com/KB/architecture/">Design and Architecture</a></div> +<div class="MI" id="Section112"><a href="http://www.codeproject.com/KB/install/">Installation</a></div> +<div class="MI" id="Section41"><a href="http://www.codeproject.com/KB/work/">Work Issues</a></div> +<div class="MI" id="Section128"><a href="http://www.codeproject.com/KB/testing/">Testing and QA</a></div> +<div class="MI" id="Section126"><a href="http://www.codeproject.com/KB/codegen/">Code Generation</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=7" onclick="return ToggleMenu('Chapter7');">General Reading</a></div> +<div class="MenuSectionBlock" id="Chapter7" style="display: none;"> +<div class="MI" id="Section60"><a href="http://www.codeproject.com/KB/books/">Book Chapters</a></div> +<div class="MI" id="Section61"><a href="http://www.codeproject.com/KB/book-reviews/">Book Reviews</a></div> +<div class="MI" id="Section109"><a href="http://www.codeproject.com/KB/hardware-review/">Hardware Reviews</a></div> +<div class="MI" id="Section63"><a href="http://www.codeproject.com/KB/interviews/">Interviews</a></div> +<div class="MI" id="Section62"><a href="http://www.codeproject.com/KB/scrapbook/">Scrapbook</a></div> +<div class="MI" id="Section48"><a href="http://www.codeproject.com/KB/system/">Hardware & System</a></div> +</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Content/Chapter.aspx?chptId=12" onclick="return ToggleMenu('Chapter12');">Third Party Products</a></div> +<div class="MenuSectionBlock" id="Chapter12" style="display: none;"> +<div class="MI" id="Section65"><a href="http://www.codeproject.com/KB/showcase/">Product Showcase</a></div> +<div class="MI" id="Section124"><a href="http://www.codeproject.com/KB/solution-center/">Solution Center</a></div> +</div> +</div> +<div style="margin-top: 5px;"></div> +<div class="MenuCat">Services</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Jobs/List.aspx">Job Board</a></div> +<div class="MenuChapter"><a href="http://www.codeproject.com/script/Catalog/index.aspx">Component Catalog</a></div> +<div class="MenuChapter"><a href="http://www.codeproject.com/Services/TradePub.aspx">Free Magazines</a></div> +<div style="margin-top: 5px;"></div> +<div class="MenuCat">Feature Zones</div> +<div class="MenuChapter"><a href="http://www.codeproject.com/kb/Showcase/">Product Showcase</a></div> +<div class="MenuChapter"><a href="http://www.codeproject.com/Zones/IBM/">IBM DeveloperWorks</a></div> +<div class="MenuChapter"><a href="http://www.codeproject.com/Zones/WhitePapers/">WhitePapers / Webcasts</a></div> +<div class="MenuChapter"><a href="http://www.codeproject.com/redir.aspx?adid=9054">.NET Bug Tracking</a></div> +<div class="MenuChapter"><a href="http://www.codeproject.com/redir.aspx?adid=8763">ASP.NET Web Hosting</a></div> +<div style="margin-top: 5px;"></div> + + + <div style="margin: auto; width: 150px;"><iframe src="EventView.aspx_files/ServeHTML_002.html" scrolling="no" width="150" frameborder="0" height="80"></iframe> + </div> + + <div style="margin: 10px auto auto; width: 160px;"><iframe src="EventView.aspx_files/ServeHTML_003.html" scrolling="no" width="160" frameborder="0" height="600"></iframe> + </div> +</div> + +<div id="ctl00_ArticlePane" class="ArticlePane"> + + +<table class="SearchHeaderBar" width="100%" cellspacing="0"> +<tbody><tr> +<td style="white-space: nowrap; width: 60%;" valign="middle" align="right"> +<form method="get" action="/info/search.aspx" name="Search" style="margin: 0pt;"> +<b>Search </b> +<input class="SmallText" name="artkw" style="width: 200px;"> +<select class="SmallText" style="font-weight: bold;" name="sbo"> +<option value="kw" selected="true">Articles</option> +<option value="fm">Messages</option> +<option value="s">Jobs</option> +<option value="ctlk">Search Catalog</option> + +</select> +<input class="SmallText" style="font-weight: bold;" value=" Go! " type="submit"> +</form> +</td> + +<td class="TinyText" style="white-space: nowrap;"> +<a href="http://www.codeproject.com/info/search.aspx">Advanced Search</a><br> +<a href="http://www.codeproject.com/script/Content/SiteMap.aspx">Sitemap</a> + +</td> +</tr> +</tbody></table> + + <a name="Main"></a> + <span id="ctl00_ResultMessage"></span> + + + + <div id="ctl00_ArtDiv"> + <table border="0" cellpadding="0" cellspacing="0"> + <tbody><tr valign="top"> + <td valign="top" width="100%"> + +<table> + +</table> + + + + +<div class="SmallText"> +<img src="EventView.aspx_files/print.gif" alt="print" style="vertical-align: middle;" width="16" height="16"><a id="ctl00_ArticleHeaderLinks_PrintLnk" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?display=Print">Print</a> + +<img src="EventView.aspx_files/report.gif" alt="Broken Article?" style="vertical-align: middle;" width="16" height="16"><a id="ctl00_ArticleHeaderLinks_BrokenLnk" href="http://www.codeproject.com/script/Articles/Report.aspx?aid=13164">Report</a> + + + + + + + +<style type="text/css"> +#ATD { + position: absolute; + top: -90px; + left: -5000px; + z-index: 200; + display: none; + white-space:nowrap; + background-color:white; + padding:10px; + border: solid 1px #999; +} +</style> +<span id="SBI"><img src="EventView.aspx_files/add.gif" id="ctl00_ArticleHeaderLinks_AddTo_Img" alt="add" style="vertical-align: middle;" width="16" height="16"> +<a href="#">Share</a></span> +<div style="left: 274px; top: 303px;" id="ATD"> + +<script language="JavaScript" type="text/javascript"> +var socialLinks = new social(); +socialLinks.addtoMethod=1; +socialLinks.Horizontal=false; +socialLinks.Showname=true; +socialLinks.DrawLinks("socialLinks", document.location.href, escape(document.title), 100, 0, "SmallText Bold", "AddTo"); +socialLinks.setupMenu(); +</script><div><a class="AddTo" title="Add this page to Digg" onclick="return socialLinks.addto(0);" href="#"><img src="EventView.aspx_files/AddTo_Digg.png" width="16" align="absmiddle" border="0" height="16"> Digg</a> </div><div><a class="AddTo" title="Add this page to Del.icio.us" onclick="return socialLinks.addto(1);" href="#"><img src="EventView.aspx_files/AddTo_Delicious.png" width="16" align="absmiddle" border="0" height="16"> Del.icio.us</a> </div><div><a class="AddTo" title="Add this page to Google" onclick="return socialLinks.addto(2);" href="#"><img src="EventView.aspx_files/AddTo_Google.png" width="16" align="absmiddle" border="0" height="16"> Google</a> </div><div><a class="AddTo" title="Add this page to Windows Live" onclick="return socialLinks.addto(3);" href="#"><img src="EventView.aspx_files/AddTo_Live.png" width="16" align="absmiddle" border="0" height="16"> Windows Live</a> </div><div><a class="AddTo" title="Add this page to Yahoo! MyWeb" onclick="return socialLinks.addto(4);" href="#"><img src="EventView.aspx_files/AddTo_Yahoo.png" width="16" align="absmiddle" border="0" height="16"> Yahoo! MyWeb</a> </div><div><a class="AddTo" title="Add this page to Technorati" onclick="return socialLinks.addto(5);" href="#"><img src="EventView.aspx_files/AddTo_Technorati.png" width="16" align="absmiddle" border="0" height="16"> Technorati</a> </div><div><a class="AddTo" title="Add this page to Blink" onclick="return socialLinks.addto(6);" href="#"><img src="EventView.aspx_files/AddTo_Blink.png" width="16" align="absmiddle" border="0" height="16"> Blink</a> </div><div><a class="AddTo" title="Add this page to Facebook" onclick="return socialLinks.addto(7);" href="#"><img src="EventView.aspx_files/AddTo_Facebook.png" width="16" align="absmiddle" border="0" height="16"> Facebook</a> </div><div><a class="AddTo" title="Add this page to Furl" onclick="return socialLinks.addto(8);" href="#"><img src="EventView.aspx_files/AddTo_Furl.png" width="16" align="absmiddle" border="0" height="16"> Furl</a> </div><div><a class="AddTo" title="Add this page to Simpy" onclick="return socialLinks.addto(9);" href="#"><img src="EventView.aspx_files/AddTo_Simpy.png" width="16" align="absmiddle" border="0" height="16"> Simpy</a> </div><div><a class="AddTo" title="Add this page to Reddit" onclick="return socialLinks.addto(10);" href="#"><img src="EventView.aspx_files/AddTo_Reddit.png" width="16" align="absmiddle" border="0" height="16"> Reddit</a> </div><div><a class="AddTo" title="Add this page to Newsvine" onclick="return socialLinks.addto(11);" href="#"><img src="EventView.aspx_files/AddTo_Newsvine.png" width="16" align="absmiddle" border="0" height="16"> Newsvine</a> </div><div><a class="AddTo" title="Add this page to Stumbleupon" onclick="return socialLinks.addto(12);" href="#"><img src="EventView.aspx_files/AddTo_stumbleupon.png" width="16" align="absmiddle" border="0" height="16"> Stumbleupon</a> </div><div><a class="AddTo" title="Add this page to Mr. Wong" onclick="return socialLinks.addto(13);" href="#"><img src="EventView.aspx_files/AddTo_MrWong.png" width="16" align="absmiddle" border="0" height="16"> Mr. Wong</a> </div> +</div> + + +<img src="EventView.aspx_files/discuss.gif" alt="Discuss" style="vertical-align: middle;" width="15" height="16"> <a href="#_comments">Discuss</a> + +<img src="EventView.aspx_files/mail.gif" alt="Recommend Article" style="vertical-align: middle;" width="16" height="16"> <a id="ctl00_ArticleHeaderLinks_Recommend" href="http://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=13164">Email</a> +</div> + </td> + <td style="text-align: right; white-space: nowrap; width: 100px;"> + <table id="CurRat"><tbody><tr><td> +<table><tbody><tr><td id="ctl00_ArticleRating_VL" style="white-space: nowrap;" class="SmallText" align="right"> +<span id="ctl00_ArticleRating_VoteLabel">5 votes for this Article.</span></td> + +<td><table border="1" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td width="20" align="left" bgcolor="White" height="7"><img src="EventView.aspx_files/red.gif" width="20" align="middle" border="0" height="7"></td> + <td width="20" align="left" bgcolor="White" height="7"><img src="EventView.aspx_files/red.gif" width="20" align="middle" border="0" height="7"></td> + <td width="20" align="left" bgcolor="White" height="7"><img src="EventView.aspx_files/red.gif" width="20" align="middle" border="0" height="7"></td> + <td width="20" align="left" bgcolor="White" height="7"><img src="EventView.aspx_files/red.gif" width="20" align="middle" border="0" height="7"></td> + <td style="padding: 0px; white-space: nowrap;" width="20" align="left" bgcolor="White" height="7"><img src="EventView.aspx_files/red.gif" width="8" align="middle" border="0" height="7"><img src="EventView.aspx_files/white.gif" width="12" align="middle" border="0" height="7"></td> + </tr> +</tbody></table> +<span id="ctl00_ArticleRating_Votes" class="SmallText"></span></td></tr> +<tr id="ctl00_ArticleRating_PopularityRow"> + <td colspan="2" class="SmallText" align="right"> +<a id="ctl00_ArticleRating_PopularityLnk" title="Calculated as rating x Log10(# votes)" href="http://www.codeproject.com/script/Articles/TopArticles.aspx?ta_so=1">Popularity: 3.08</a> +<span id="ctl00_ArticleRating_PopularityLbl"></span><span id="ratingVal">Rating: <b>4.40</b> out of 5</span></td> +</tr> +</tbody></table> + + + +</td> + <td> +<div> +<table class="HistTable" title="Voting Distribution. Recent data only"><tbody><tr><td><img src="EventView.aspx_files/t.html" alt="" title="" width="10" border="0" height="1"><br>1</td> +<td><img src="EventView.aspx_files/t.html" alt="" title="" width="10" border="0" height="1"><br>2</td> +<td><img src="EventView.aspx_files/pollcol.gif" alt="1 vote, 20.0%" title="1 vote, 20.0%" width="10" border="0" height="6"><br>3</td> +<td><img src="EventView.aspx_files/pollcol.gif" alt="1 vote, 20.0%" title="1 vote, 20.0%" width="10" border="0" height="6"><br>4</td> +<td><img src="EventView.aspx_files/pollcol.gif" alt="3 votes, 60.0%" title="3 votes, 60.0%" width="10" border="0" height="20"><br>5</td> +</tr></tbody></table> +</div> + + + +</td></tr></tbody></table> + </td> + </tr> + </tbody></table> + + + + + + + + + + + + + + + + + + <div id="contentdiv"> + + <!-- Main Page Contents Start --> + + +<!-- Article Starts --> + +<p><img alt="The Event Viewer" src="EventView.aspx_files/EventView.GIF" width="578" height="316"></p> +<h2>Introduction</h2> +<p>This article will explain how to add a user name to the Events that are logged in to the Event Viewer.</p> +<h2>Background</h2> +<p>I needed to add user names to events that were being logged, and I +could not find anything directly on target. Microsoft's website stated +to simply add the SID to the <code>ReportEvent</code> function. It did +not tell how to get the SID. After much more investigation, I found +something written in another programming language that got the user +SID, so I translated it into C and combined it with what I was doing.</p> +<h2>Using the code</h2> +<p>I wrote a standalone program first to test out what I wanted to do +at work. I will provide all the relevant portions here so that you can +simply paste into your project something that works.</p><div class="SmallText" id="premain0" style="width: 100%; cursor: pointer;"><img preid="0" src="EventView.aspx_files/minus.gif" id="preimg0" width="9" height="9"><span preid="0" style="margin-bottom: 0pt;" id="precollapse0"> Collapse</span></div><pre style="margin-top: 0pt;" id="pre0"> HANDLE hToken; + HANDLE g_eventHandle = NULL; + <span class="code-keyword">int</span> rc; + DWORD dwLength = <span class="code-digit">0</span>; + PTOKEN_USER pTokenUser = NULL; + TCHAR *params[<span class="code-digit">1</span>]; + + <span class="code-comment">//</span><span class="code-comment"> in order to use ReportEvent we must first Register Event +</span> + g_eventHandle = RegisterEventSource(NULL, _T(<span class="code-string">"</span><span class="code-string">SID_TEST"</span>)); + OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken); + + <span class="code-comment">//</span><span class="code-comment"> Get required buffer size and allocate the PTOKEN_USER buffer. +</span> + <span class="code-keyword">if</span> (!GetTokenInformation( + hToken, <span class="code-comment">//</span><span class="code-comment"> handle to the access token +</span> + TokenUser, <span class="code-comment">//</span><span class="code-comment"> get information about the token's groups +</span> + (LPVOID) pTokenUser, <span class="code-comment">//</span><span class="code-comment"> pointer to TOKEN_USER buffer +</span> + <span class="code-digit">0</span>, <span class="code-comment">//</span><span class="code-comment"> size of buffer +</span> + &dwLength <span class="code-comment">//</span><span class="code-comment"> receives required buffer size +</span> + )) + { + <span class="code-keyword">if</span> (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + <span class="code-keyword">goto</span> Cleanup; + + pTokenUser = (PTOKEN_USER)HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, dwLength); + + <span class="code-keyword">if</span> (pTokenUser == NULL) + <span class="code-keyword">goto</span> Cleanup; + } + + <span class="code-comment">//</span><span class="code-comment"> Get the token group information from the access token. +</span> + <span class="code-keyword">if</span> (!GetTokenInformation( + hToken, <span class="code-comment">//</span><span class="code-comment"> handle to the access token +</span> + TokenUser, <span class="code-comment">//</span><span class="code-comment"> get information about the token's groups +</span> + (LPVOID) pTokenUser, <span class="code-comment">//</span><span class="code-comment"> pointer to TOKEN_USER buffer +</span> + dwLength, <span class="code-comment">//</span><span class="code-comment"> size of buffer +</span> + &dwLength <span class="code-comment">//</span><span class="code-comment"> receives required buffer size +</span> + )) + { + <span class="code-keyword">goto</span> Cleanup; + } + + params[<span class="code-digit">0</span>] = <span class="code-keyword">const_cast</span><span class="code-keyword"><</span>TCHAR*<span class="code-keyword">></span>(<span class="code-string">"</span><span class="code-string">test string"</span>); + + <span class="code-comment">//</span><span class="code-comment"> the actual call that places the event into the Event Viewer +</span> + rc = ReportEvent(g_eventHandle, EVENTLOG_INFORMATION_TYPE, <span class="code-digit">0</span>, <span class="code-digit">0</span>, + pTokenUser-<span class="code-keyword">></span>User.Sid,<span class="code-comment">//</span><span class="code-comment"> the sid goes here <------- +</span> + <span class="code-digit">1</span>, <span class="code-digit">0</span>, (LPCTSTR *)params, NULL); + +Cleanup: + + <span class="code-comment">//</span><span class="code-comment"> Free the buffer for the token . +</span> + <span class="code-keyword">if</span> (pTokenUser != NULL) + HeapFree(GetProcessHeap(), <span class="code-digit">0</span>, (LPVOID)pTokenUser); + + <span class="code-comment">//</span><span class="code-comment"> i am finished with the Event +</span> + DeregisterEventSource(g_eventHandle);</pre> +<h2>Points of Interest</h2> +<p>That's all there is to it. The <code>GetTokenInformation</code> function has to be called twice; if you have too much or too little allocated for your SID, the function will fail.</p> +<p>The Event View with our entry:</p> +<p><img alt="The Event Viewer" src="EventView.aspx_files/EventView2.GIF" width="577" height="390"></p> + + + +<!-- Article Ends --> + + + <!-- Main Page Contents End --> + + </div> + + + <form name="aspnetForm" method="post" action="EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick" id="aspnetForm" style="margin: 0pt; padding: 0pt;"> +<div> +<input name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwMDUyNjYzMjgPZBYCZg9kFgQCCw9kFgYCAw8PFgIeB1Zpc2libGVnZGQCCQ8PFgIfAGdkZAIMDw8WAh8AZ2RkAgwPZBYKAgcPZBYOAgEPZBYCZg8WAh4LXyFJdGVtQ291bnRmZAIDD2QWCmYPDxYCHgtOYXZpZ2F0ZVVybAUnL0tCL3dpbnNkay9FdmVudFZpZXcuYXNweD9kaXNwbGF5PVByaW50ZGQCAQ8PFgIfAgUmL3NjcmlwdC9BcnRpY2xlcy9SZXBvcnQuYXNweD9haWQ9MTMxNjRkZAICDw8WAh8AaGRkAgMPDxYCHwBoZGQCBQ8PFgIfAgUxL3NjcmlwdC9jb21tb24vVGVsbEZyaWVuZC5hc3B4P29idGlkPTImb2JpZD0xMzE2NGRkAgUPZBYEAgEPZBYCAgEPDxYCHgRUZXh0BRk1IHZvdGVzIGZvciB0aGlzIEFydGljbGUuZGQCBg9kFgJmD2QWBAIBDw8WBB8DBRBQb3B1bGFyaXR5OiAzLjA4HwIFKS9zY3JpcHQvQXJ0aWNsZXMvVG9wQXJ0aWNsZXMuYXNweD90YV9zbz0xZGQCBQ8WAh8DBRxSYXRpbmc6IDxiPjQuNDA8L2I+IG91dCBvZiA1ZAIZD2QWCgIBD2QWBAIBDxYCHglpbm5lcmh0bWwFsQI8cD5UaGlzIGFydGljbGUgaGFzIG5vIGV4cGxpY2l0IGxpY2Vuc2UgYXR0YWNoZWQgdG8gaXQgYnV0IG1heSBjb250YWluIHVzYWdlIHRlcm1zIGluIHRoZSBhcnRpY2xlIHRleHQgb3IgdGhlIGRvd25sb2FkIGZpbGVzIHRoZW1zZWx2ZXMuIElmIGluIGRvdWJ0IHBsZWFzZSBjb250YWN0IHRoZSBhdXRob3IgdmlhIHRoZSBkaXNjdXNzaW9uIGJvYXJkIGJlbG93LjwvcD48cD5BIGxpc3Qgb2YgbGljZW5zZXMgYXV0aG9ycyBtaWdodCB1c2UgY2FuIGJlIGZvdW5kIDxhIGhyZWY9Ii9pbmZvL0xpY2Vuc2VzLmFzcHgiPmhlcmU8L2E+PC9wPmQCAg9kFgICAQ8QZGQWAGQCBQ8WAh8BAgFkAgcPFgIfAwXjCDxoMj5PdGhlciBwb3B1bGFyIEFwcGxpY2F0aW9ucyAmIFRvb2xzIGFydGljbGVzOjwvaDI+PHVsPjxsaT48YSBocmVmPSIvS0IvYXBwbGljYXRpb25zL3RvZG9saXN0Mi5hc3B4Ij5Ub0RvTGlzdCA1LjcuMiAtIEEgc2ltcGxlIGJ1dCBlZmZlY3RpdmUgd2F5IHRvIGtlZXAgb24gdG9wIG9mIHlvdXIgdGFza3M8L2E+PGRpdiBjbGFzcz0iU21hbGxUZXh0Ij5BIGhpZXJhcmNoaWNhbCB0YXNrIG1hbmFnZXIgd2l0aCBuYXRpdmUgWE1MIHN1cHBvcnQgZm9yIGN1c3RvbSByZXBvcnRpbmcuPC9kaXY+PC9saT48bGk+PGEgaHJlZj0iL0tCL21pc2NjdHJsL2dyaWRjdHJsLmFzcHgiPk1GQyBHcmlkIGNvbnRyb2wgMi4yNjwvYT48ZGl2IGNsYXNzPSJTbWFsbFRleHQiPkEgZnVsbHkgZmVhdHVyZWQgTUZDIGdyaWQgY29udHJvbCBmb3IgZGlzcGxheWluZyB0YWJ1bGFyIGRhdGEuIFRoZSBncmlkIGlzIGEgY3VzdG9tIGNvbnRyb2wgZGVyaXZlZCBmcm9tIENXbmQ8L2Rpdj48L2xpPjxsaT48YSBocmVmPSIvS0IvdGlwcy9TZWxmLWdlbmVyYXRpbmctY29kZS5hc3B4Ij5Qcm9ncmFtbWluZyBTZWxmLWdlbmVyYXRpbmcgQ29kZSBmb3IgV2luZG93cyBBcHBsaWNhdGlvbnM8L2E+PGRpdiBjbGFzcz0iU21hbGxUZXh0Ij5FeGVjdXRpbmcgVkMrKyBjb2RlcyBpbiBTVEFDSyBvciBIRUFQPC9kaXY+PC9saT48bGk+PGEgaHJlZj0iL0tCL2NzL0FzeW5jTWV0aG9kSW52b2NhdGlvbi5hc3B4Ij5Bc3luY2hyb25vdXMgTWV0aG9kIEludm9jYXRpb248L2E+PGRpdiBjbGFzcz0iU21hbGxUZXh0Ij5Ib3cgdG8gdXNlIC5ORVQgdG8gY2FsbCBtZXRob2RzIGluIGEgbm9uLWJsb2NraW5nIG1vZGUuPC9kaXY+PC9saT48bGk+PGEgaHJlZj0iL0tCL2dyYXBoaWNzL3plZGdyYXBoLmFzcHgiPkEgZmxleGlibGUgY2hhcnRpbmcgbGlicmFyeSBmb3IgLk5FVDwvYT48ZGl2IGNsYXNzPSJTbWFsbFRleHQiPkxvb2tpbmcgZm9yIGEgd2F5IHRvIGRyYXcgMkQgbGluZSBncmFwaHMgd2l0aCBDIz8gSGVyZSdzIHlldCBhbm90aGVyIGNoYXJ0aW5nIGNsYXNzIGxpYnJhcnkgd2l0aCBhIGhpZ2ggZGVncmVlIG9mIGNvbmZpZ3VyYWJpbGl0eSwgdGhhdCBpcyBhbHNvIGVhc3kgdG8gdXNlLjwvZGl2PjwvbGk+PC91bD5kAgkPDxYCHwBnZGQCDQ9kFgJmD2QWAgIBD2QWAmYPZBYCAgkPFgIfAGgWAgIBDxBkZBYAZAIbDw8WAh8AZ2RkAh0PDxYCHwBnZGQCJQ8WAh8AaGQCCQ8PFgIfAgUnL3NjcmlwdC9BcnRpY2xlcy9BcnRpY2xlLmFzcHg/YWlkPTEzMTY0ZGQCDw8WAh8DBQsyMiBGZWIgMjAwNmQCEQ8PFgQfAwUOU21pdGhhIFZpamF5YW4fAgUqL3NjcmlwdC9NZW1iZXJzaGlwL1Byb2ZpbGVzLmFzcHg/bWlkPTI4OTcwZGQCEw8WAh8DBRxDb3B5cmlnaHQgMjAwNiBieSBtYXRodGhhaW9zZGShPV3AOgLvzgl3lxlPtzVYrtdCMA==" type="hidden"> +</div> + + + + <h2>License</h2> + <div id="ctl00_LicenseTerms"><p>This +article has no explicit license attached to it but may contain usage +terms in the article text or the download files themselves. If in doubt +please contact the author via the discussion board below.</p><p>A list of licenses authors might use can be found <a href="http://www.codeproject.com/info/Licenses.aspx">here</a></p></div> + + <h2>About the Author</h2> + + + +<table width="100%" border="0" cellpadding="0" cellspacing="5"> +<tbody><tr valign="top"> +<td id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberPhotoTable" style="width: 155px;" valign="top"> + <b><a id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberProfileLink" href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=661994">maththaios</a></b><br><br> + <center></center><br> + <span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberType" class="SmallText"></span> + +</td> + +<td> + I am a computer programmer in Florida.<br> + + <table> + <tbody><tr id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_jobTitleRow"> + <td class="SmallText" nowrap="nowrap">Occupation: </td> + <td width="100%"><span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberJobTitle" class="SmallText">Software Developer (Senior)</span></td> +</tr> + + + + + <tr id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_locationRow"> + <td class="SmallText">Location: </td> + <td width="100%"><span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberLocation" class="SmallText"><img src="EventView.aspx_files/US.gif" alt="United States" width="16" height="11"> United States</span></td> +</tr> + + </tbody></table> + +</td> +</tr> +</tbody></table> + + <br> + + + <table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr valign="top"> + <td style="width: 100%;"> + <h2>Other popular Applications & Tools articles:</h2><ul><li><a href="http://www.codeproject.com/KB/applications/todolist2.aspx">ToDoList 5.7.2 - A simple but effective way to keep on top of your tasks</a><div class="SmallText">A hierarchical task manager with native XML support for custom reporting.</div></li><li><a href="http://www.codeproject.com/KB/miscctrl/gridctrl.aspx">MFC Grid control 2.26</a><div class="SmallText">A fully featured MFC grid control for displaying tabular data. The grid is a custom control derived from CWnd</div></li><li><a href="http://www.codeproject.com/KB/tips/Self-generating-code.aspx">Programming Self-generating Code for Windows Applications</a><div class="SmallText">Executing VC++ codes in STACK or HEAP</div></li><li><a href="http://www.codeproject.com/KB/cs/AsyncMethodInvocation.aspx">Asynchronous Method Invocation</a><div class="SmallText">How to use .NET to call methods in a non-blocking mode.</div></li><li><a href="http://www.codeproject.com/KB/graphics/zedgraph.aspx">A flexible charting library for .NET</a><div class="SmallText">Looking +for a way to draw 2D line graphs with C#? Here's yet another charting +class library with a high degree of configurability, that is also easy +to use.</div></li></ul> + </td> + <td> + <script type="text/javascript">document.write(unescape("%3ca%20href%3d%22http%3a%2f%2fwww.codeproject.com%2fRedir.aspx%3fadid%3d8672%26way%3dban%22%20target%3d%22_blank%22%20rel%3d%22nofollow%22%3e%3cimg%20src%3d%22http%3a%2f%2fwww.codeproject.com%2fscript%2fAdm%2fServeImg.aspx%3fFile%3d%252fscript%252fAdm%252fimages%252f20082-300x250.png%26C%3dFalse%26adid%3d8672%22%20alt%3d%22%22%20border%3d%220%22%20width%3d%22300%22%20height%3d%22250%22%3e%3c%2fa%3e"));</script><a href="http://www.codeproject.com/Redir.aspx?adid=8672&way=ban" target="_blank" rel="nofollow"><img src="EventView.aspx_files/ServeImg.html" alt="" width="300" border="0" height="250"></a> + + </td> + </tr> + </tbody></table> + + <table id="ctl00_RateArticleRow" class="RatingBar" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td><a href="#_top">Article Top</a></td> + <td align="right"> +<table width="100%" cellpadding="0" cellspacing="0"><tbody><tr> + + + + <td id="voteTbl" style="white-space: nowrap;" class="SmallText" align="right"> + + <table><tbody><tr> + <td id="ctl00_RateArticle_SignIn" nowrap="nowrap"><a href="#SignUp">Sign Up</a> to vote for this article</td> + + + + + + <td><span id="ctl00_RateArticle_ErrorMessage"></span></td> + </tr></tbody></table> + + </td> +</tr></tbody></table> + +<div id="RateComDiv" style="display: none;"> +<table width="100%"><tbody><tr valign="top"><td width="100%" align="right">Your reason for this vote:</td> +<td><textarea id="RateComment" rows="5" cols="60" style="width: 285px; float: right;"></textarea> +</td></tr></tbody></table></div> + + + +</td> + </tr> +</tbody></table> + + </form> + + <div style="overflow: hidden; margin-left: 40px; white-space: nowrap;"> + <script type="text/javascript">document.write(unescape("%3ca%20href%3d%22http%3a%2f%2fwww.codeproject.com%2fRedir.aspx%3fadid%3d9389%26way%3dban%22%20target%3d%22_blank%22%20rel%3d%22nofollow%22%3e%3cimg%20src%3d%22http%3a%2f%2fwww.codeproject.com%2fscript%2fAdm%2fServeImg.aspx%3fFile%3d%252fscript%252fAdm%252fimages%252fIS_bannerW_468x60_Feb09.gif%26C%3dFalse%26adid%3d9389%22%20alt%3d%22%22%20border%3d%220%22%20width%3d%22468%22%20height%3d%2260%22%3e%3c%2fa%3e"));</script><a href="http://www.codeproject.com/Redir.aspx?adid=9389&way=ban" target="_blank" rel="nofollow"><img src="EventView.aspx_files/ServeImg_002.html" alt="" width="468" border="0" height="60"></a> + <iframe src="EventView.aspx_files/ServeLinks.html" scrolling="no" width="300" frameborder="0" height="60"></iframe> + + + + </div> + + <a name="_comments"></a><!-- Forum Start --> +<div id="_MessageBoard" onclick="return SwitchMessage(event, null)"> + <table id="ForumTable" class="Frm_MainTable" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgAlert"><b>You must <a href="http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick">Sign In</a> to use this message board.</b></td> + </tr><tr> + <td><form action="/script/Forums/SetOptions.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&floc=%2fKB%2fwinsdk%2fEventView.aspx" method="get" style="margin: 0pt; padding: 0pt;"> + <input name="fid" value="271767" type="hidden"><input name="currentQS" value="?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&floc=%2fKB%2fwinsdk%2fEventView.aspx" type="hidden"><input name="floc" value="/KB/winsdk/EventView.aspx" type="hidden"><table width="100%" border="0" cellpadding="3" cellspacing="0"> + <tbody><tr class="Frm_HeaderRow1"> + <td style="white-space: nowrap;"><img src="EventView.aspx_files/forum_faq.gif" alt="FAQ" width="16" align="middle" border="0" height="16"> <a href="http://www.codeproject.com/script/Forums/FAQ.aspx"><b>FAQ</b></a> </td><td style="white-space: nowrap; text-align: right;">Noise Tolerance<select size="1" class="Frm_DropDown" name="noise"> + <option value="1">Very High</option><option value="2">High</option><option selected="selected" value="3">Medium</option><option value="4">Low</option><option value="5">Very Low</option> + </select></td><td colspan="2" style="white-space: nowrap; text-align: right;"><img src="EventView.aspx_files/forum_search.gif" alt="Search" width="16" align="top" border="0" height="15"> <a href="http://www.codeproject.com/script/Forums/Search.aspx?fid=271767">Search Messages</a> </td><td style="text-align: right;"><input value="Set Options" name="SetOpt" class="Frm_Button" type="submit"></td> + </tr><tr class="Frm_HeaderRow2"> + <td style="width: 100%;"> </td><td style="white-space: nowrap; text-align: right;">Layout<select size="1" class="Frm_DropDown" name="view"> + <option selected="selected" value="Quick">Normal</option><option value="Topic">Expand Root Messages</option><option value="Expanded">Expand All Messages</option><option value="Thread">Thread View</option><option value="Normal">No Javascript (slow)</option><option value="Preview">No Javascript Preview</option> + </select> </td><td style="white-space: nowrap;">Per page<select size="1" class="Frm_DropDown" name="mpp"> + <option value="10">10</option><option selected="selected" value="25">25</option><option value="50">50</option> + </select> </td><td colspan="2"> </td> + </tr> + </tbody></table> + </form></td> + </tr><tr> + <td><a name="xx0xx"></a><table width="100%" border="0" cellpadding="2" cellspacing="0"> + <tbody><tr class="Frm_NavigationBar"> + <td> </td><td>Msgs 1 to 5 of 5 (Total in Forum: 5) (<a href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick">Refresh</a>)</td><td style="text-align: right; white-space: nowrap;"><span class="Frm_HL">First</span><span class="Frm_HL">Prev</span><span class="Frm_HL">Next</span></td> + </tr> + </tbody></table></td> + </tr><tr> + <td><table class="Frm_MsgTable" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td><img src="EventView.aspx_files/t.gif" alt="" width="1" border="0" height="5"></td> + </tr> +<!-- Start Message head --> + + <tr class="MsgHd Rt HdUnSel" id="F2480096_h0"> + <td width="100%"><table class="QuickHd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" width="16"><a name="xx2480096xx"></a><img src="EventView.aspx_files/msg_general.gif" alt="General" width="16" align="top" height="16"></td><td class="Frm_MsgSubject"><a id="DynMessLink" name="2480096" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2480096#xx2480096xx">Nice example but do you have vb.net version.</a></td><td style="width: 20px; white-space: nowrap;"><img src="EventView.aspx_files/member_sm.gif" title="member" alt="member" border="0" height="16"></td><td class="Frm_MsgAuthor"><a href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=4911548">Member 4911548</a></td><td class="Frm_MsgDate" style="vertical-align: top; white-space: nowrap;">17:31 25 Mar '08 </td> + </tr> + </tbody></table></td> + </tr><!-- End Message head --> + + <tr id="F2480096_h1" style="display: none;"> + <td width="100%"><table class="QuickBd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" style="width: 16px;"><img src="EventView.aspx_files/t.gif" alt="" width="16" height="1"></td><td class="MsgBd BdSel"><table width="100%" border="0" cellpadding="0" cellspacing="5"> + <tbody><tr> + <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td colspan="2">hi, i using vb.net windows application. Can you help me translate to vb.net version? Many thanks for you. <br><br><div class="ForumMod">modified on Tuesday, March 25, 2008 11:14 PM</div><br></td> + </tr><tr style="vertical-align: middle;"> + <td class="Frm_MsgFt"><a class="Frm_MHL" href="http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick">Sign In</a>·<a class="Frm_MHL" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&sort=Position&tid=2480096" title="View Thread">View Thread</a>·<a class="Frm_MHL" href="http://www.codeproject.com/script/Forums/View.aspx?fid=271767&msg=2480096" title="Get permanent link">PermaLink</a></td><td class="Frm_MsgFt" style="text-align: right;"><span id="MVF2480096" style="white-space: nowrap;"></span></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr><tr class="Quick"> + <td class="Frm_MsgRtDivide"><img src="EventView.aspx_files/t.gif" alt="" width="1" border="0" height="1"></td> + </tr> +<!-- Start Message head --> + + <tr class="MsgHd Rt HdUnSel" id="F1446862_h0"> + <td width="100%"><table class="QuickHd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" width="16"><a name="xx1446862xx"></a><img src="EventView.aspx_files/msg_general.gif" alt="General" width="16" align="top" height="16"></td><td class="Frm_MsgSubject"><a id="DynMessLink" name="1446862" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1446862#xx1446862xx">What about using LookupAccountName ?</a></td><td style="width: 20px; white-space: nowrap;"><img src="EventView.aspx_files/member_sm.gif" title="member" alt="member" border="0" height="16"></td><td class="Frm_MsgAuthor"><a href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=2903095">lumoryel</a></td><td class="Frm_MsgDate" style="vertical-align: top; white-space: nowrap;">5:22 12 Apr '06 </td> + </tr> + </tbody></table></td> + </tr><!-- End Message head --> + + <tr id="F1446862_h1" style="display: none;"> + <td width="100%"><table class="QuickBd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" style="width: 16px;"><img src="EventView.aspx_files/t.gif" alt="" width="16" height="1"></td><td class="MsgBd BdSel"><table width="100%" border="0" cellpadding="0" cellspacing="5"> + <tbody><tr> + <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td colspan="2">Hi there !<br><br>I +found another possibility to get the SID of a certain user. I'm calling +GetUserName() (which returns the username of the current thread) and +put the username into LookupAccountName(). This returns the SID for +this user.<br><br><code><br>bool __fastcall +CreateEventLogEntry(AnsiString source, AnsiString message, WORD +event_type, BYTE * data, int data_size, DWORD event_id)<br>{<br><br> HANDLE g_eventHandle = NULL;<br> TCHAR *params[1];<br><br> message = "\n\n" + message + "\n\n";<br> params[0] = message.c_str();<br><br> g_eventHandle = RegisterEventSource(NULL, source.c_str());<br> if(g_eventHandle==NULL)<br> {<br> ShowMessage("CreateEventLogEntry: RegisterEventSource() Failed !");<br> return false;<br> }<br><br> TCHAR lpBuffer[100];<br> unsigned long size = 100;<br><br> if(!GetUserName(lpBuffer, &size))<br> {<br> ShowMessage("CreateEventLogEntry: GetUserName() Failed !");<br> DeregisterEventSource(g_eventHandle);<br> return false;<br> }<br><br> SID Sid;<br> DWORD Sid_Size = 28;<br> TCHAR ReferencedDomainName[100];<br> DWORD DomainName_Size = 100;<br> SID_NAME_USE snu = SidTypeUser;<br><br> if(!LookupAccountName(NULL,<br> lpBuffer,<br> &Sid,<br> &Sid_Size,<br> ReferencedDomainName,<br> &DomainName_Size,<br> &snu))<br> {<br> ShowMessage("CreateEventLogEntry: LookUpAccountName() Failed !");<br> DeregisterEventSource(g_eventHandle);<br> return false;<br> }<br><br> if(!ReportEvent(g_eventHandle, event_type, 0, event_id,<br> &Sid, 1, data_size, (LPCTSTR *)params, data))<br> {<br> ShowMessage("CreateEventLogEntry: ReportEvent() Failed !");<br> DeregisterEventSource(g_eventHandle);<br> return false;<br> }<br><br> DeregisterEventSource(g_eventHandle);<br><br> return true;<br>}<br></code><br></td> + </tr><tr style="vertical-align: middle;"> + <td class="Frm_MsgFt"><a class="Frm_MHL" href="http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick">Sign In</a>·<a class="Frm_MHL" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&sort=Position&tid=1446862" title="View Thread">View Thread</a>·<a class="Frm_MHL" href="http://www.codeproject.com/script/Forums/View.aspx?fid=271767&msg=1446862" title="Get permanent link">PermaLink</a></td><td class="Frm_MsgFt" style="text-align: right;"><span id="MVF1446862" style="white-space: nowrap;"></span></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr><tr class="Quick"> + <td class="Frm_MsgDivide"><img src="EventView.aspx_files/t.gif" alt="" width="1" border="0" height="1"></td> + </tr> +<!-- Start Message head --> + + <tr class="MsgHd HdUnSel" id="F1447008_h0"> + <td width="100%"><table class="QuickHd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" width="34"><a name="xx1447008xx"></a><img src="EventView.aspx_files/msg_general.gif" alt="General" width="16" align="top" height="16"></td><td class="Frm_MsgSubject"><a id="DynMessLink" name="1447008" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1447008#xx1447008xx">Re: What about using LookupAccountName ?</a></td><td style="width: 20px; white-space: nowrap;"><img src="EventView.aspx_files/member_sm.gif" title="member" alt="member" border="0" height="16"></td><td class="Frm_MsgAuthor"><a href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=661994">maththaios</a></td><td class="Frm_MsgDate" style="vertical-align: top; white-space: nowrap;">6:26 12 Apr '06 </td> + </tr> + </tbody></table></td> + </tr><!-- End Message head --> + + <tr id="F1447008_h1" style="display: none;"> + <td width="100%"><table class="QuickBd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" style="width: 34px;"><img src="EventView.aspx_files/t.gif" alt="" width="34" height="1"></td><td class="MsgBd BdSel"><table width="100%" border="0" cellpadding="0" cellspacing="5"> + <tbody><tr> + <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td colspan="2">I +tried this code and I found 2 things. 1st, My IDE (Visual Studio) +reported at the end of the function that the stack around the variable +Sid was corrupted. 2nd the user name, for some reason, did not show in +the event viewer. I was able to fix the stack corruption by changing +SID to PSID and calling LookupAccountName twice. The first time with +Sid_Size == 0, the Sid_Size is then set by this function so that PSID +can be dynamically allocated, the second call fills out the sid +proberly. I am not sure why the user name is not showing up in the +event viewer. But I will continue to investigate. <br></td> + </tr><tr style="vertical-align: middle;"> + <td class="Frm_MsgFt"><a class="Frm_MHL" href="http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick">Sign In</a>·<a class="Frm_MHL" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&sort=Position&tid=1446862" title="View Thread">View Thread</a>·<a class="Frm_MHL" href="http://www.codeproject.com/script/Forums/View.aspx?fid=271767&msg=1447008" title="Get permanent link">PermaLink</a></td><td class="Frm_MsgFt" style="text-align: right;"><span id="MVF1447008" style="white-space: nowrap;"></span></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr><tr class="Quick"> + <td class="Frm_MsgRtDivide"><img src="EventView.aspx_files/t.gif" alt="" width="1" border="0" height="1"></td> + </tr> +<!-- Start Message head --> + + <tr class="MsgHd Rt HdUnSel" id="F1395426_h0"> + <td width="100%"><table class="QuickHd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" width="16"><a name="xx1395426xx"></a><img src="EventView.aspx_files/msg_general.gif" alt="General" width="16" align="top" height="16"></td><td class="Frm_MsgSubject"><a id="DynMessLink" name="1395426" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1395426#xx1395426xx">Nice but i have a question</a></td><td style="width: 20px; white-space: nowrap;"><img src="EventView.aspx_files/member_sm.gif" title="member" alt="member" border="0" height="16"></td><td class="Frm_MsgAuthor"><a href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=61934">nesculcas</a></td><td class="Frm_MsgDate" style="vertical-align: top; white-space: nowrap;">1:23 6 Mar '06 </td> + </tr> + </tbody></table></td> + </tr><!-- End Message head --> + + <tr id="F1395426_h1" style="display: none;"> + <td width="100%"><table class="QuickBd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" style="width: 16px;"><img src="EventView.aspx_files/t.gif" alt="" width="16" height="1"></td><td class="MsgBd BdSel"><table width="100%" border="0" cellpadding="0" cellspacing="5"> + <tbody><tr> + <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td colspan="2">Hello, <br><br>This +is interesting, I always wonder why my desriptions on event viewer +never appear only like the message i wrote, it always preceded some +text telling that the source was not valid or something like that. But +now i try your code and once again there's a preceding text... only the +difference it's now different the contents <img src="EventView.aspx_files/smiley_tongue.gif" alt="Poke tongue" align="top"> <br><br>My question is why in my teste de description tells this: (note i use the source text 'teste' and event id=0)<br><br>The +description for Event ID ( 0 ) in Source ( teste ) cannot be found. The +local computer may not have the necessary registry information or +message DLL files to display messages from a remote computer. You may +be able to use the /AUXSOURCE= flag to retrieve this description; see +Help and Support for details<br><br>Thanks <br><br>Nuno<br></td> + </tr><tr style="vertical-align: middle;"> + <td class="Frm_MsgFt"><a class="Frm_MHL" href="http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick">Sign In</a>·<a class="Frm_MHL" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&sort=Position&tid=1395426" title="View Thread">View Thread</a>·<a class="Frm_MHL" href="http://www.codeproject.com/script/Forums/View.aspx?fid=271767&msg=1395426" title="Get permanent link">PermaLink</a></td><td class="Frm_MsgFt" style="text-align: right;"><span id="MVF1395426" style="white-space: nowrap;"></span></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr><tr class="Quick"> + <td class="Frm_MsgDivide"><img src="EventView.aspx_files/t.gif" alt="" width="1" border="0" height="1"></td> + </tr> +<!-- Start Message head --> + + <tr class="MsgHd HiVote HdUnSel" id="F1396115_h0"> + <td width="100%"><table class="QuickHd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" width="34"><a name="xx1396115xx"></a><img src="EventView.aspx_files/msg_general.gif" alt="General" width="16" align="top" height="16"></td><td class="Frm_MsgSubject"><a id="DynMessLink" name="1396115" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1396115#xx1396115xx">Re: Nice but i have a question</a></td><td style="width: 20px; white-space: nowrap;"><img src="EventView.aspx_files/member_sm.gif" title="member" alt="member" border="0" height="16"></td><td class="Frm_MsgAuthor"><a href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=661994">maththaios</a></td><td class="Frm_MsgDate" style="vertical-align: top; white-space: nowrap;">10:04 6 Mar '06 </td> + </tr> + </tbody></table></td> + </tr><!-- End Message head --> + + <tr id="F1396115_h1" style="display: none;"> + <td width="100%"><table class="QuickBd" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td class="Frm_MsgIndent" style="width: 34px;"><img src="EventView.aspx_files/t.gif" alt="" width="34" height="1"></td><td class="MsgBd BdSel"><table width="100%" border="0" cellpadding="0" cellspacing="5"> + <tbody><tr> + <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tbody><tr> + <td colspan="2">if +I understand your question, so seem to be having a problem with the +message itself, and not in reguards to adding the user name to the +message. I did a search on The Code Project for the ReportEvent +function, and this one, +http://www.codeproject.com/system/xeventlog.asp, seems to be on target +for the problems you are having. I hope this helps.<br>Matt <br></td> + </tr><tr style="vertical-align: middle;"> + <td class="Frm_MsgFt"><a class="Frm_MHL" href="http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fKB%2fwinsdk%2fEventView.aspx%3ffid%3d271767%26df%3d90%26mpp%3d25%26noise%3d3%26sort%3dPosition%26view%3dQuick">Sign In</a>·<a class="Frm_MHL" href="http://www.codeproject.com/KB/winsdk/EventView.aspx?fid=271767&df=90&mpp=25&sort=Position&tid=1395426" title="View Thread">View Thread</a>·<a class="Frm_MHL" href="http://www.codeproject.com/script/Forums/View.aspx?fid=271767&msg=1396115" title="Get permanent link">PermaLink</a></td><td class="Frm_MsgFt" style="text-align: right;"><span id="MVF1396115" style="white-space: nowrap;">5.00/5 (1 vote) </span></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table></td> + </tr><tr> + <td><img src="EventView.aspx_files/t.gif" alt="" width="1" border="0" height="5"></td> + </tr> + </tbody></table></td> + </tr><tr> + <td><table width="100%" cellpadding="2" cellspacing="0"> + <tbody><tr class="Frm_Footer"> + <td>Last Visit: 9:27 4 Mar '09 Last Update: 9:27 4 Mar '09 </td><td style="text-align: right; white-space: nowrap;"></td> + </tr> + </tbody></table></td> + </tr> + </tbody></table> +</div><p class="SmallText"><img src="EventView.aspx_files/msg_general.gif" alt="General" width="16" align="top" height="16"> General <img src="EventView.aspx_files/msg_news.gif" alt="News" width="16" align="top" height="16"> News <img src="EventView.aspx_files/msg_question.gif" alt="Question" width="16" align="top" height="16"> Question <img src="EventView.aspx_files/msg_answer.gif" alt="Answer" width="16" align="top" height="16"> Answer <img src="EventView.aspx_files/msg_joke.gif" alt="Joke" width="16" align="top" height="16"> Joke <img src="EventView.aspx_files/msg_rant.gif" alt="Rant" width="16" align="top" height="16"> Rant <img src="EventView.aspx_files/msg_admin.gif" alt="Admin" width="16" align="top" height="16"> Admin </p> +<!-- Forum End --> + + + + + + </div> + + <table width="100%"> + <tbody><tr valign="top"> + <td class="TinyText" align="left"> + <a id="ctl00_PermaLink" href="http://www.codeproject.com/script/Articles/Article.aspx?aid=13164">PermaLink</a> | + <a id="ctl00_PrivacyLink" href="http://www.codeproject.com/info/privacy.aspx">Privacy</a> | + <a id="ctl00_TermsOfUseLink" href="http://www.codeproject.com/info/TermsOfUse.aspx">Terms of Use</a> + <br>Last Updated: 22 Feb 2006<br> + Editor: <a id="ctl00_ArticleEditor" href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=28970">Smitha Vijayan</a><br> + </td> + <td class="TinyText" valign="top" align="right"> + Copyright 2006 by maththaios<br>Everything else + Copyright © <a href="mailto:webmaster@codeproject.com">CodeProject</a>, 1999-2009 <br> + Web20 | + <a id="ctl00_AdvertiseLink" href="http://www.codeproject.com/info/MediaKit.aspx">Advertise on the Code Project </a> + </td> + </tr> + + </tbody></table> + + <center> + + </center> + +</div> +</div> + +<div> + + +</div> + +<br> +<script type="text/javascript" language="Javascript">//<![CDATA[ +if (document.all) try {window.attachEvent("oncopy",copyCode);}catch(e){}; +//]]></script> + +<script type="text/javascript" language="Javascript" src="EventView.aspx_files/TogglePre.js"></script> +<script type="text/javascript" language="Javascript">//<![CDATA[ +$(document).ready(function() {RetrieveJobsSummary('Th',13164,2,43,"4,159,175,24,51,184,118,153");}); +//]]></script> + + +</body></html>
\ No newline at end of file |