|
Change the application priority
|
Total Hit (3010) |
The application's priority - and more in general the thread's priority - indicates how the application is "important" for the CPU. The more the priority is hight the more the CPU will dedicate his time to execute it.
In .NET the priority of a thread is indicated to the Thread.Priority property. B
....Read More |
Rating
|
|
|
Check whether Microsoft Word is installed
|
Total Hit (3144) |
The .NET frameworks provides a set of classes that let you work with the Registry, so it is quite easy to create routine that looks for specific keys to determine whether a program is installed or not. For example, the following code checks whether Microsoft Word is installed on the local computer:
....Read More |
Rating
|
|
|
Create a command-line filter utility
|
Total Hit (2860) |
The Console class exposes two properties that make it very simple to create command-line utilities that work as filters, exactly like the FIND and MORE utilities that are provided with the operating system. The Console.In property returns a TextReader object that reads from the standard input channe
....Read More |
Rating
|
|
|
Determine the Windows version
|
Total Hit (3181) |
You don't need to call any Windows API function in VB.NET to determine which version of Windows your application is running on, because this information is exposed by the Environment.OSVersion property. For example, if you run this code under Windows 2000:
«Code LangId=2»
Console.WriteLine(Envir
....Read More |
Rating
|
|
|
Determine type and number of CPUs
|
Total Hit (4545) |
There is no method call that directly retuns information about the number and type of installed CPU(s). However, this information is stored in a few environment variables, so it's just a matter of extracting it with the Environment.GetEnvironmentVariable method:
«Code LangId=2»
' this code is me
....Read More |
Rating
|
|
|
Duplicate the SET operating system command
|
Total Hit (2661) |
The Environment.GetEnvironmentVariables property returns the list of all the environment variables, as an IDictionary object. If you want to display them sorted by their name, as the SET command does at the prompt, you need the following tricky code:
«Code LangId=2»
' Get all the variables, as a
....Read More |
Rating
|
|
|
Launch another process in a specified directory
|
Total Hit (2770) |
The System.Diagnostics.Process class provides several methods to launch and controls other Windows processes. For example, the following code sample shows how to run Notepad, pass arguments to it, and run it from inside a given intial directory:
«Code LangId=2»
' this code assumes that you have
....Read More |
Rating
|
|
|
List all COM components on local machine
|
Total Hit (2903) |
The following routine parses the registry and lists all the installed COM components:
«Code LangId=2»
' this code assumes that you have used this Imports statement
' Imports Microsoft.Win32
' Print ProgID, CLSID, and path of all the COM components
' installed on this computer.
Sub DisplayC
....Read More |
Rating
|
|
|
List all running Windows processes
|
Total Hit (2829) |
The System.Diagnostics.Process class exposes the GetProcesses static method, that returns a list of all running processes. It is quite easy to leverage this feature to display all running processes in a ListBox or ComboBox control:
«Code LangId=2»
' This code assume that you've used the followin
....Read More |
Rating
|
|
|
Prevent a second process instance from running
|
Total Hit (3057) |
VB6 developers can use the App.PrevInstance property to check whether there is another instance of the same process already running on the current machine. This property isn't available any longer in VB.NET, so you must retrieve this information by using the properties of the Process object.
The
....Read More |
Rating
|
|
|
Retrieve information about the current user
|
Total Hit (2590) |
You can easily retrieve information about the current user by means of a few properties of the Environment class. The Environment.UserName returns the name of the user; the Environment.UserInteractive property returns True if the user is an interactive user; the UserDomainName returns the user's dom
....Read More |
Rating
|
|
|
Retrieve Windows and System directories
|
Total Hit (3247) |
In VB.NET you don't need to call the GetWindowsDirectory and GetSystemDirectory API functions to retrieve the path the Windows and System directories. Retrieving the System directory is as simple as calling the Environment.SystemDirectory property:
«Code LangId=2»
Dim sysDir As String = Environm
....Read More |
Rating
|
|
|
Retrieving special system paths
|
Total Hit (2715) |
The GetFolderPath method of the Environment class lets you retrieve the path of several important system directories. For example, here's how you determine the path of the Desktop directory for the current user:
«Code LangId=2»
Console.WriteLine(Environment.GetFolderPath _
(Environment.Spec
....Read More |
Rating
|
|
|
Wait for a process to terminate
|
Total Hit (3611) |
You can use the VB.NET Shell command (in the Microsoft.VisualBasic namespace) to run an external process and wait for its termination, but you can get better control if you work directly with the Process class in the System.Diagnostics namespace. You can start a process with the Start static method
....Read More |
Rating
|
|
|
Write a console utility to kill a process
|
Total Hit (3023) |
The System.Diagnostics.Process class exposes two methods that let you kill a process: CloseMainWindow should be used with processes that have a graphical interface, whereas the Kill method should be used for apps without a user interface (or those whose main window is disable and can't process the W
....Read More |
Rating
|
|
|
Write a console utility to list processes
|
Total Hit (4153) |
The Process class provides all you need to create a command-line utility that lists all the processes running on the system and all the related information. This utility is therefore similar to the Windows Task Manager, except you can run it from the command prompt. All processes are sorted alphabet
....Read More |
Rating
|
|
|
Showing help
|
Total Hit (2760) |
The System.Windows.Forms.Help class encapsulates the HTML Help 1.0 engine and lets you display the index, the search page, or a specific topic in an HTML file in HTML Help format or a compiled help file (.chm) authored with the HTML Help Workshop or some third party tool.
This class exposes two
....Read More |
Rating
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|