
Recently I was reading an article on some Windows 7 forums on how to change Windows Logon Background. There are manual steps which helps me to change the longon background, but its tedious if I have to do it manually everytime. So I decided to make a tool which can do it for me.
I start up a new project in Visual Studio 2010 and create a new windows application. I am not writing about how I did it, I am just giving away this tool for use. Just Browse and click Change Logon Screen and you are done.

Press WIN+L to lock your computer and check your new logon screen. There is only one limitation, you cannot select an image which is larger than 256KB.
Download: Win7 LogonScreenChanger.zip (49.21 kb)
Source Code: Win7LogonScreenChanger.zip (139.44 kb)
We all know about a feature called User Account Control (UAC) which introduced with the launch of Windows Vista. By default, UAC is enabled and provides users a better and safer computing experience, but most of the users find it irritating when the UAC prompts everytime they try to run a program. Disabling UAC is not recommended at all.
With UAC enabled programmers find it difficult to access some of the locations on the local drive. Programatically you cannot write or create a file or directory in root partition, inside Program Files, System32 folder and some other locations. Recently I ran into a same problem where I have to access System32 folder, create new folders and copy files from one location on my system to this folder. With UAC disabled this is pretty easy, no security settings and no runtime errors or exceptions. Usually you cannot ask the users to disable UAC and then use the application, so therefore I made my application compatible with UAC and YES!!! you will be prompted with the confirmation box to run the application with administrator privileges. In Windows Vista and Windows 7, even if you are an administrator of your machine you do not have the complete access to resources even if you are an administrator. So in order to make your application run with full administrator rights follow the steps below. This will work the same if you run your application with “Run as Administrator” option which you see when you right-click the application.
Create a new application in Visual Studio. Right-click project and add a new item.

From the Add New Item box select Application Manifest File.
In the manifest file un-comment the following line:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Build your applicaton….and when the build is complete you will see the security shield icon accompanying your application icon. A dialogue box appear in front of the user to run the application with full administrative privileges.
Since I have started using BlogEngine.NET I never thought of using any other open source blog engine. To me BlogEngine is the most extensible blogging platform availableat present. As a popular blogging, engine blog engine users faces a lot of spam comments. I was so totally annoyed and even after moderating comments I have to manually go and delete the comments. After some search I found an extesion from Joel Thoms. Simple and easy to use, dont even require moderation.This extension passes the commnets to Akismet spam database which then checks approves or disapprove commnets.
To get it working you need an API Key which you can get for free at http://akismet.com. Once you get an API key extract the files in App_Code/Extensions folder and jump to your Extension section under Settings.

Once you save your settings you are done. NO MORE SPAM.
Download: AkismetExtension.zip (3.55 kb)
The easiest way to find out the processor architecture is to use the Environment class GetEnvironmentVariable method.
Console.WriteLine(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"));
This will print the processor architecture on the console window i.e. x86 and x64 for 32-bit and 64-bit respectively.
Recently I was asked by one of my friend how to call a web service directly from a stored procedure. He needs to track IP addresses using a stored procedures so, I suggested him two ways to call a web service using the SQL Procedure.
I personally tried using the first way to call a web service but was not successful. Then I learnt about SQL CLR programming with Visual Studio and C# and get it done in a first go. As a good friend I create the whole project for my friend. And if your thinking that this is going to be a difficult, this is not so.
To start creating a project, open Visual Studio and create a new project.

Before the project gets loaded completely, you will be asked to add database reference. Here select the database you want to build the assembly for. If you don’t want to add a database reference then just simply cancel. But if you choose the reference to add at this point then this would really be of help as this will allow you to deploy your assembly directly to the SQL Server database but if you have not then you need to write some SQL scripts.

NOTE: If you have added a database reference then it doesn’t mean that your assembly is build specifically for that database you can still deploy your assembly in other database also.
As I am creating a stored procedure, I then have to add a New Item to my project. Right-click project choose Add>Stored Procedure. Here give a name of your choice to stored procedure. In my case it is IPInfo.

Change the static method here to accept a parameter. Our parameter will be an IP address, which I have set as of string type.
public static void GetIPInfo(string IP)
{
//Do something here
}
Now the question here is from where we can the information of the IP Addresses? I do some search and found a website http://www.geobytes.com. It offers some rich information of the IP Address you want to track, so out of five sources I choose to go with geobytes.
Lets take a quick look at the code. This is not a web service as you can see from the code below, I am just making a http request and then get the response in an XML form so I can easily traverse the nodes and read/save the information I received.
string XMLResponse; IPAddress = IP; byte[] XMLResults; string str = "http://www.geobytes.com/IpLocator.htm?GetLocation&template=xml.txt" + "&IpAddress=" + IP; XMLResults = new WebClient().DownloadData(str.ToString()); XMLResponse = Encoding.UTF8.GetString(XMLResults);
Note the fourth line where I have built the URL. The parameter Template should always have a value to xml.txt. If you change the name, it won’t throw any error but the data received cannot be read and saved in a database table. Convert the response to string format and then read the nodes one by one using the below code.
try
{
XmlDocument document = new XmlDocument();
document.LoadXml(XMLResponse);
XmlNode documentElement = document.DocumentElement;
if (documentElement.HasChildNodes)
{
for (int i = 0; i < documentElement.ChildNodes.Count; i++)
{
if (documentElement.ChildNodes[i].NodeType == XmlNodeType.Element)
{
switch (documentElement.ChildNodes[i].Name)
{
case "locationcode":
LocationCode = documentElement.ChildNodes[i].InnerText;
break;
case "fips":
FIPS104 = documentElement.ChildNodes[i].InnerText;
break;
case "iso2":
ISO2 = documentElement.ChildNodes[i].InnerText;
break;
case "iso3":
ISO3 = documentElement.ChildNodes[i].InnerText;
break;
case "ison":
ISON = documentElement.ChildNodes[i].InnerText;
break;
case "internet":
Internet = documentElement.ChildNodes[i].InnerText;
break;
case "countryid":
CountryID = documentElement.ChildNodes[i].InnerText;
break;
case "country":
Country = documentElement.ChildNodes[i].InnerText;
break;
case "regionid":
RegionID = documentElement.ChildNodes[i].InnerText;
break;
case "region":
Region = documentElement.ChildNodes[i].InnerText;
break;
case "code":
RegionCode = documentElement.ChildNodes[i].InnerText;
break;
case "adm":
Admn1Code = documentElement.ChildNodes[i].InnerText;
break;
case "cityid":
CityID = documentElement.ChildNodes[i].InnerText;
break;
case "city":
City = documentElement.ChildNodes[i].InnerText;
break;
case "latitude":
Latitude = documentElement.ChildNodes[i].InnerText;
break;
case "longitude":
Longitude = documentElement.ChildNodes[i].InnerText;
break;
case "timezone":
TimeZone = documentElement.ChildNodes[i].InnerText;
break;
case "certainty":
Certainty = documentElement.ChildNodes[i].InnerText;
break;
}
}
}
}
}
catch (Exception) { }
Build you project and you will see a DLL file in your debug/release folder. But this will not work. You will still have to set some permission level to assembly and to SQL Server database.
Set Assembly Permissions
Before you build the final version of the assembly go the project properties and set the permissions as shown below.
Under Build select option for Generate Serialization Assembly to On.

Under Database select Permission Level to Unsafe

SQL Server Permissions
If you find problems while deploying your assembly, then make sure you have CLR enabled and set the Trustworthy property for the database to ON.
You can find all the scripts in the attached solution below.
Deploying your assembly
To deploy your assembly use the below SQL command:
CREATE ASSEMBLY IPTracker from 'C:\IPInfo.dll' WITH PERMISSION_SET = EXTERNAL_ACCESS GO
To create a stored procedure whcih in trun calls the SQL method from the deployed assembly:
CREATE PROC TrackIP(@IP as nvarchar(50))AS -- [Assembly Name].[Class Name].[CLR function Name] EXTERNAL NAME IPTracker.StoredProcedures.GetIPInfo GO
And execute the procedure to get the IP information.

Download: IPInfo.zip (19.46 kb)