How to create and delete custom event logs in Windows using C# .NET Framework? In my latest project, I need to have a custom Windows event log to keep track of all the bugs reported by my applications. Therefore, I created an application to create this custom event log file.
First of all, you need to have using System.Diagnostics; We need to use System.Diagnostics namespace to create or remove custom event logs.
Codes to create custom event logs
These codes will create an event log called ‘LogName’ and EventSource as ‘ApplicationName’.
Codes to delete custom event logs
Hope this will help…
How to modify Windows System Registry Values with C#? As usual, you need to use Microsoft.Win32 Namespace ~ using Microsoft.Win32;. Let’s take Windows Application Event Logs values as an example. I want to change the MaxSize and Retention values in Application Event Log file by using C#.
Codes to change Windows System Registry values
RegistryKey TestEventLog = Registry.LocalMachine.OpenSubKey(“System\\CurrentControlSet\\Services\\EventLog\\Application”,true);
TestEventLog.SetValue(“MaxSize”, “102367232″, RegistryValueKind.DWord);
TestEventLog.SetValue(“Retention”, “0″, RegistryValueKind.DWord);
Above codes open Application event log and with write permission (,true). It changes both MaxSize and Retention values.
Just change the codes to suit your need.
How to read and write Windows System Registry Keys and Values? I need to create a value at Windows System Registry for my project lately. It is used for SCOM discovery. I need a Windows System Registry key to determine that the server is the server that SCOM going to monitor.
First thing to do in your C#. Add using Microsoft.Win32; RegistryKey and Registry requires Microsoft.Win32 as the assembly reference.
Here are the codes that write Windows System Registry Keys.
RegistryKey JayceOoiKey = Registry.LocalMachine.CreateSubKey(“SOFTWARE\\JayceOoi”);
This will create key JayceOoi under HKEY_LOCAL_MACHINE\SOFTWARE\.
To read Test string value from HKEY_LOCAL_MACHINE\SOFTWARE\JayceOoi\
string Output = JayceOoiKey.GetValue(“Test”);
These are the methods that I use to read and write Windows System Registry Keys and Values. Hope it will help in your programming work.
AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. I have using it lately to track web usage by loading data from the web log files. However, it does not show authenticated users which I wanted. I searched at AWStats website and found out that Authenticated users list is part of the features. And the demo have Authenticated users list too. Hmm… What should I do to turn Authenticated users list on?
Authenticated users list at AWStats
Posted by Jayce Ooi as Programming
ASP.NET C# Input TextBox value by pressing Enter key. Huh? I want to get the value of the textbox without click on the submit button. But getting the textbox value by just pressing enter key on keyboard. How am I going to do so? The page just refresh if I press enter key. I want the enter key link to the submit button. Therefore, whenever I press enter key, I will get the textbox value.
Here is the solution to get it done. By adding defaultbutton variable in form or asp:Panel will solve it.
<form id=”form1″ defaultbutton=”Button1″ runat=”server”>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
<asp:Button ID=”Button1″ runat=”server” Text=”Button” OnClick=”Button1_Click” />
<asp:Label ID=”Label1″ runat=”server” Text=”Label”></asp:Label>
<asp:Panel ID=”Panel1″ defaultbutton=”Button2″ runat=”server”>
<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox>
<asp:Button ID=”Button2″ runat=”server” Text=”Button” OnClick=”Button2_Click” />
<asp:Label ID=”Label2″ runat=”server” Text=”Label”></asp:Label>