The help you needed in C, C++, MFC
Complete tutorials with free source code
PDF Print E-mail

Using Visual Studio as the editor to write drivers

If you use notepad or similar editor to write the source code for drivers, you will feel very uncomfortable because it do not provide the facilities Visual Studio gives you such as syntax highlighting, auto complete etc which you used in normal C++ programs. You can just open the C source file of the driver in Visual Studio and write the driver in that. But, still it will not provide useful features such as auto complete.

 

Function parameters are shown In Visual Studio

Function parameters are shown in Visual Studio

 

Auto complete feature in Visual Studio

Auto complete feature provided in Visual Studio

But, you can make these features work by few simple steps.

  • Create a new project in Visual Studio. Select project type as Win32 project and check the option "Empty Project".
  • In the solution explorer, right click on Source Files entry and select Add->Existing Item.
  • Then, browse and select the source file of your driver. It is not necessary that this file is in the project directory of the project you just created. Because you are using WDK as the driver builder, this source file should be in a seperate directory where "makefile" and "sources" files are located.
  • Then, select Tools->Options in Visual Studio. In options dialog, select Projects and Solutions->VC++ Directories.

Visual Studio options dialog. how to set VC++ include directories

  • Then, Select Include files from combo box at top right. You will see a list of include directories. You have to add the appropriate include directory of the WDK at the bottom of this list. You can see in the above picture the directory I have added. Because i am writing the driver for Windows XP, I have choosen the include directory of Windows XP (wxp).

Now, try to edit the C source file you added. The above mentioned useful features should be working now. Remember that you cannot compile the project in Visual Studio. You use Visual Studio just as the editor. To compile and build your source file, you have to use command prompt of WDK.