Recent

Detect Internet Connection in C#

There are numerous ways to find out whether or not there is an internet connection present. One of the quickest ways is to use the InternetGetConnectedState API. Here is how

Using BitBlt to Copy Images in C#

The BitBlt function simply performs a bit-block transfer of the color data corresponding to a rectangle of pixels from a source device context into a destination device context. You can

SynchronizationContext in C#

A SynchronizationContext allows one thread to communicate with another thread. For example, to update the User Interface thread (UI Thread) from an outside thread you could do something like the

Using LINQ for Queries

LINQ?is?very?good?and?efficient?when?it?comes?to?handling?data?coming?from?a?datasource.?This?little?example?creates?a?Table?object.?Then?creates?a?DataContext?to?interpret?the?Table?data,?and?finally?does?a?query?to?extract?the?wanted?data. ????????[Table(Name?=?”Courses”)] ????????public?class?Courses?//Create?Courses?Table ????????{ ????????????[Column(IsPrimaryKey?=?true,?DbType?=?”BIGINT?NOT?NULL?IDENTITY”,?IsDbGenerated?=?true)] ????????????public?Int32?CourseID;?//Field ????????????[Column] ????????????public?string?CourseDesc;?//Field ????????} ????????????????using?(DataContext?dcCourses?=?new?DataContext(“CONNECTION_STRING))?//Connect?to?DB ????????????????{ ????????????????????var?data?=?(from?c?in?_Courses ????????????????????????????????where?c.CourseID?==?ComboBox1.SelectedIndex ????????????????????????????????select?new?{?c.CourseDesc?} ????????????????????).FirstOrDefault();?//Select?CourseID?That?Corresponds?to?ComboBox?Selection ????????????????????TextBox1.Text?=?data.Name;?//Display ?????????????????}

DevX - Software Development Resource

Reading a File Backwards Quickly in C#

The classes in .NET are structured to read files from the beginning to end. Hard drives are structured like that, sometimes though there is a dire need to read a

DevX - Software Development Resource

Locking Your Computer with C#

In order to lock your computer, you need to use the following two APIs: [DllImport(“user32.dll”)] public static extern void LockWorkStation(); [DllImport(“user32.dll”)] public static extern int ExitWindowsEx(int uFlags, int dwReason); You

DevX - Software Development Resource

Minimizing All Open Windows

It is quite easy to minimize all currently opened windows with C#. All you need to know is a few APIs: FindWindowSendMessageTimeout Here is a small example: public partial class

DevX - Software Development Resource

Prevent Shutdown from a C# App

It is possible to prevent a system shutdown from within your C# apps. Basically the premise is as follows: Override the WndProc event so that when a system shutdown event