Saturday, February 5, 2011

How to make program to get device drivers - Part 2

In order to get device drivers which installed on your computer we will write method its name (GetDriversList), this method is it most important part of our program which it consists of sub-method its name (GetDriver), which get and store driver informaion.
So the first stage is to bring a list containing the device drivers installed on your computer, which, as we mentioned previously that it found in the Registry Editor, and then brought the information contained in the key of each driver.
To store information about each driver, you declare the structure (DriverInfo) containing 6 fields to store the name, version, date, manufacture ....... of each driver.
The method that bring in device drivers (GetDriversList), supplied with a parameter determines if we want to get all the drivers, including drivers that are installed with the system or only drivers that you installed after you install the system. In order to get that we test the value of the manufacturer (drvManufacture) If it is equal to (Microsoft), this means that the driver was already installed with the system and we do not need to do a backup copy of it.

struct DriverInfo  //structure for storing driver informations
    public string drvName;
    public string drvVersion;
    public string drvManufacture;
    public string drvDate;
    public string drvInfPath;
    public string drvInfSection;

Thursday, February 3, 2011

How to make program to get device drivers

Where do we find device drivers??
We can we find device drivers in the registry editor and in the following key:
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Class

Where this key (Class) contains many of the subkeys that represent device drivers, as we see in the picture that the names of these keys is a (GUID)
Under these subkeys we find other sub-keys have their names, like this: 0000-0001-0002 - etc.

In these keys we find the required information, as we see there are values in these keys contain information on device drivers, most important of these values are:

  1. DriverDesc: which represents the name of the driver
  2. DriverVersion: which is the version of the driver
  3. DriverDate: which is the date the driver
  4. InfPath: which represents the name of the Inf file for this this driver, which is located in the folder: C: \ Windows \ Inf
  5. ProviderName: which represents the name of the manufacturer of this driver, this is very important since by this value we can identify the drives that install automatically with the system and its value is 'Microsoft', either to have installed by the user will be value certainly not a 'Microsoft', but 'Intel' Or 'Relatek' for example

The program interface:
The program interface consists of ListView to display the drives and their information, as well as some buttons such as: Get Drivers List and Backup Drivers.

How we will make a backup??
We can do it by the Inf file for each driver (*. Inf)Where contains inside a section containing the names of the files that make up the driver.
Our task is to extract the names of the files from the Inf file and then copy it to the location specified by the user.
This lesson was just a paving and a brief explanation for the work through the program in general .. It sounds easy for a moment, but its implementation will be a little harder, for reasons I will mention in other parts of this lesson, but surely there is nothing difficult or impossible in the world of programming.
Author: Abdullah Alezzo

Monday, January 31, 2011

GDI+ Introducation - C#

What is GDI+ :

This technique is the upgraded version of the GDI are used in the drawing for the making new tools, or for any purpose that needs to draw such a chart ...

Principles in the GDI +:
Create a new project Windows Forms Application, and then place a button on the form and type in the event Click:
Graphics myg = this.CreateGraphics();
Pen myp = new Pen(Brushes.Red, 2);
myg.DrawLine(myp, 0, 0, this.Width, this.Height);
Try the code ...
The code will draw a red line of the upper-right corner of the form to the lower right corner ...


Sunday, January 30, 2011

Tip: Adding files to your program and extract them when need

Add executable files or other files, and then extract it from the program in one line:

  • Open a new project first, then add the files you want as follows:
  1. From the solution explorer window
  2. Open My project
  3. And select resources
  4. Then select the type of files and select Other
  5. Add files and then clicking on the Add existing file
  6. And select the files you want
    • When you want to retrieve files and save them on your computer You only write this line:
    My.Computer.FileSystem.WriteAllBytes(OutPutFN, My.Resources.ResourceFN, False)
    OutPutFN: a name and location of the file after extraction
    My.Resources.ResourceFN: the file that you want to extract
    False: If the file exists, do you want to overwrite it?

    What is the benefit of adding and extracting such files?

    • In terms of safety to the environment of your program, you can keep a copy of the files on which your program, and when you damage one of these files, you can restore it this way ... And this gives your program additional strength.

    Saturday, January 29, 2011

    Using Regular Expression - VB.NET

    What is Regular Expression?
    1. It is great technique to search through texts.
    2. Supported by many programming languages.
    3. It use textual formulas contain some special characters that have special meaning.

    • Imagine that you want to search for emails in a text file or search for titles in websites here comes the role of the Regular Expression optimal solution.

    The support of framework for Regular Expression:

    • Like many programming languages, the framework supports the Regular Expression through a set of classes exist in the space of names System.Text.RegularExpressions.

    Regex object is used to search through text on a certain formula Declaration for the object is like this: