Category: WinForms

Shutdown or Restart the Computer Using C#

January 8, 2009 | By | 6 Comments

The easiest way to shutdown, restart, or hibernate a computer programmatically using C# is to use the shutdown command-line tool that comes with Windows.

Continue Reading

Multithreading in .NET With the BackgroundWorker

January 4, 2009 | By | Add a Comment

Sometimes a smart client application needs to do a lengthy operation that can slow down the performance of the whole application and make it unresponsive. This can be solved by executing the operation in a separate thread using the .NET Framework’s BackgroundWorker control. The BackgroundWorker executes such operations asynchronously in a thread separate from the [...]

Continue Reading

Minimize an Application to the System Tray

December 27, 2008 | By | Add a Comment

To be able to use the System Tray in Visual Studio, drag and drop the NotifyIcon control. The important properties to set are Text and Icon.

Continue Reading

Programming for Multiple Screens in DotNET

December 21, 2008 | By | Add a Comment

This is a piece of code I used for an application that needed to be displayed in 2 screens setup as extended view. I used a simple calculation to know the selected screen’s coordinates and place the form in its center.

Continue Reading

Creating Your Own Travian Utilities

December 13, 2008 | By | 4 Comments

Travian the well known browser game has a downloadable file for developers in each of its servers that provides details of all the players of the server. The file contains a list of SQL INSERT statements, one for each player. Although the statement doesnt provide military or attack information, that can be used to cheat [...]

Continue Reading

Using Microsoft Office’s OCR Engine

December 11, 2008 | By | Add a Comment

The Microsoft Office Document Imaging library that is provided with Office 2003 and Office 2007, has Optical Character Recognition (OCR) that can extract text and layout from image files. As you can see from the code below, it doesnt need much to use it. So to start first include the COM object ‘Microsoft Office Document [...]

Continue Reading

Retrieving Icons From Executables

December 9, 2008 | By | 1 Comment

I found this code somewhere on the web two years ago. It basically gets the large (32 x 32 pixels) and small (16 x 16 pixels) icons of an executable. The function returns an Icon object that can be displayed on a form’s icon area or used as a bitmap on a picture box or [...]

Continue Reading