今天想写个驱动,在网上找来好多的VS2008+DDK环境的配置方法,可是总是不成功,经过我两个小时的努力终于成功了。发现好多别人写的总是少一部分或者不够详细,故写了这篇文章,希望对那些和我一样的人有帮助。
1、安装VS2008;
2、安装DDK;我的目录是:C:/WINDDK
3、到http://ddkwizard.assarbad.net/ 下载ddkwizard_setup_v1.2.0a、ddkbuild_bat.zip、ddkbuild_cmd.zip。
4、安装ddkwizard_setup_v1.2.0a,并将ddkbuild.bat 和 ddkbuild.cmd 拷贝到DDK安装根目录,C:/WinDDK.
5、我的电脑--->属性/高级/环境变量/系统变量/新建
其中变量名按下面设置:
2000 DDK则变量名为: W2KBASE
XP DDK则变量名为: WXPBASE
2003 sp1 DDK则变量名为: WNETBASE
WNETBASE值为DDK目录,例如我的是:C:/WinDDK/2600
6、打开VS2008
Tools——>Options——>Projects and Solutions选项中的VC++ Directories,在show directoriesfor选择Executable files增加WDK的根目录,例如我的是:C:/WINDDK
然后,在show directoriesfor选择 Library files,并添加链接库,例如我的是C:/WINDDK/2600/lib/wxp/i386
7、其中VS2008,可以发现在新建项目里面有DDK Project的选项了,里面就可以建立驱动工程来编写驱动程序了。
注意在新建Driver Object的时候,不要选择“Create PREfast configuration”,如下图所示
8、新建DDK Project之后修改SOURCE文件:
其中TARGETTYPE=后面加DRIVER;
加入以下两行:
DDKROOT=C:/WINDDK/2600; #这里要和安装目录一样
INCLUDES=$(DDKROOT)/inc;
加入[源文件]后还要在sources文件里的SOURCES=后面加上[源文件名]。比如:
SOURCES=Helloworld.c
9 编译驱动程序