Archive for the ‘C#’ Category

Runtime Scripting in .Net

The ability to ship source code with your product that can be compiled or interpreted at runtime is a very valuable asset. Video games do this all the time with things like AI allowing the end-user to easily mod the game. In compiled languages like C++, this technique is highly advantageous as it allows [...]

September 30, 2009   Posted in: C#  6 Comments

Using Ini Files In C#

An Initialization, or Ini file, is a common text based file format commonly used on the Windows platform. Today its mostly been succeeded in favor of XML files for application configuration and persisting user data. Never the less, these files still exist and are in use by many applications. In this post, we will explore [...]

July 16, 2009   Posted in: C#  2 Comments

Accessing the System Task Bar in C#

In this post I’ll show you how to access the system taskbar and obtain information like its location, size, etc. You may find yourself needing to do something like this if you had a “popup” window for instance that is always supposed to “pop up” from the system tray. This is a common feature in [...]

May 10, 2009   Posted in: C#, Programming  6 Comments

Launching and Viewing Processes in C#

You can launch a new process from a C# application by using the Process class located in the System.Diagnostics namespace. The Process class also allows you to obtain a collection of all running processes on the system.
How to Launch a New Process
Starting a process is really easy.

Process.Start( "Notepad.exe" );

And that’s it. If Notepad.exe exists on [...]

April 15, 2009   Posted in: C#, Programming  3 Comments

How To Get Screen Shot Capture in C#

It’s often necessary to programmatically get a screen shot of the desktop and save it to a file. This is pretty easy with C#; we can create a simple method that will save an image of whatever is on the screen or desktop.
Saving a Bitmap Image of the Screen
First make sure you include the System.Drawing.Imaging [...]

April 13, 2009   Posted in: C#, Programming  11 Comments

Introduction to Multithreading in C#

This article is a very basic introductory tutorial for using multiple threads in C#. I’ll explain what threads are, why you would want to use them, and how to use them. I’ll also show you several examples for creating threads, killing threads, etc.
What’s a Thread?
A computer program is generally very linear. That is, you have [...]

April 8, 2009   Posted in: C#, Programming  2 Comments

Playing an MP3 or WAV File in C#

Playing an audio file such as an MP3 or WAV is incredibly easy in C#. For WAV files you can use the SoundPlayer class found in the System.Media namespace. Playing an MP3 will require referencing the Windows Media Player COM component.

How to Play a WAV file
To play the WAV file simply create a new SoundPlayer [...]

April 5, 2009   Posted in: C#  8 Comments