Retrieve The Status of a Windows Service

Here is an easy way to get the status of a Windows service. ''' <summary> ''' Gets the status of a Windows service. ''' </summary> ''' <param name="serviceName">Name of the service.</param> ''' <returns>ServiceControllerStatus.</returns> ''' <exception cref="InvalidOperationException">Service not  found.</exception> ''' <exception cref="System.InvalidOperationException">Service  not found.</exception> Public Function ServiceStatus(serviceName As String)  As ServiceControllerStatus     Dim service As ServiceController = LoadService(serviceName)     If service IsNot Nothing Then         Return service.Status     Else         Throw New InvalidOperationException("Service not  found.")     End If End Function ''' <summary> ''' Loads the service. ''' </summary> ''' <param name="serviceName">Name of the service.</param> ''' <returns>ServiceController.</returns> Private Function LoadService(serviceName As String) As  ServiceController     Return ServiceController.GetServices().Where(Function(p)  p.ServiceName = serviceName).FirstOrDefault() End Function Here are the values for service status: ContinuePending Paused PausePending Running StartPending [...]

Retrieving Common Windows Paths

Someone asked me recently how to find the path to where Windows is installed. Well it's pretty easy using the code below: var path = Environment.GetFolderPath(Environment.SpecialFolder.Windows); Turns out there is a wealth of path information using the Environment.Special folder enumuration. Here is the output from my XP development machine: Desktop - C:\Documents and Settings\dotNetDave\Desktop Programs [...]

Windows API Code Pack for Microsoft .NET Framework

The Windows® API Code Pack for Microsoft® .NET Framework provides a source code library that can be used to access some new Windows 7 features (and some existing features of older versions of Windows operating system) from managed code. These Windows features are not available to developers today in the .NET Framework. Click here to [...]

Windows 7 Available for Download on August 6th

Developers with MSDN Subscriptions will be able to download Windows 7 RTM in English on August 6th and remaining languages by October 1st. To help developers who are developing applications for Windows 7 or updating existing applications to take advantage of new Windows 7 features, check out the Windows 7 for Developers Blog. Also, be [...]