当使用WDK(我这里版本WDK 7600.16385.1)命令行编译一个驱动程序时,进入到当前驱动所在的文件夹目录下,一般都有一个Sources文件,内容一般是:
TARGETNAME=UsbKbd TARGETTYPE=DRIVER DRIVERTYPE=WDM TARGETPATH=OBJ #TARGETLIBS=C:\98DDK\LIB\I386\FREE\Usbd.Lib TARGETLIBS=$(DDK_LIB_PATH)\Usbd.Lib INCLUDES=$(BASEDIR)\inc; SOURCES= Init.cpp \ Dispatch.cpp \ Pnp.cpp \ DeviceIo.cpp \ Usb.cpp \ DebugPrint.c \ # UsbKbd.rc NTTARGETFILES=PostBuildSteps
开启一个WDK命令行编译环境,执行下面操作:
<span style="font-size:18px;">C:\WinDDK\7600.16385.1>set >c:\1.txt</span>上面操作的意思是,将当前命令行cmd下所有的环境变量输出到c:\1.txt内,打开该文件,如下:
386=1 ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\Administrator\AppData\Roaming asl.log=Destination=file ATL_INC_PATH=C:\WinDDK\7600.16385.1\inc ATL_INC_ROOT=C:\WinDDK\7600.16385.1\inc ATL_LIB_PATH=C:\WinDDK\7600.16385.1\lib\atl\* BASEDIR=C:\WinDDK\7600.16385.1 BUILD_ALLOW_COMPILER_WARNINGS=1 BUILD_ALT_DIR=chk_wxp_x86 BUILD_DEFAULT=-ei -nmake -i -nosqm BUILD_DEFAULT_TARGETS=-386 BUILD_MAKE_PROGRAM=nmake.exe BUILD_MULTIPROCESSOR=1 BUILD_OACR=1 COFFBASE_TXT_FILE=C:\WinDDK\7600.16385.1\bin\coffbase.txt CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=XT1-20140726YGA ComSpec=C:\Windows\system32\cmd.exe CPU=AMD64 CRT_INC_PATH=C:\WinDDK\7600.16385.1\inc\crt CRT_LIB_PATH=C:\WinDDK\7600.16385.1\lib\crt\* DDKBUILDENV=chk DDK_INC_PATH=C:\WinDDK\7600.16385.1\inc\ddk DDK_LIB_DEST=C:\WinDDK\7600.16385.1\lib\wxp DDK_LIB_PATH=C:\WinDDK\7600.16385.1\lib\wxp\* DDK_TARGET_OS=WinXP DEPRECATE_DDK_FUNCTIONS=1 DEVMGR_SHOW_DETAILS=1 DRIVER_INC_PATH=C:\WinDDK\7600.16385.1\inc\ddk FP_NO_HOST_CHECK=NO HALKIT_INC_PATH=C:\WinDDK\7600.16385.1\inc\ddk HALKIT_LIB_PATH=C:\WinDDK\7600.16385.1\lib\wxp\* HOMEDRIVE=C: HOMEPATH=\Users\Administrator IFSKIT_INC_PATH=C:\WinDDK\7600.16385.1\inc\ddk IFSKIT_LIB_DEST=C:\WinDDK\7600.16385.1\lib\wxp IFSKIT_LIB_PATH=C:\WinDDK\7600.16385.1\lib\wxp\* Include=C:\WinDDK\7600.16385.1\inc\api KMDF_INC_PATH=C:\WinDDK\7600.16385.1\inc\wdf\kmdf KMDF_LIB_PATH=C:\WinDDK\7600.16385.1\lib\wdf\kmdf\* LANGUAGE_NEUTRAL=0 Lib=C:\WinDDK\7600.16385.1\lib LINK_LIB_IGNORE=4198 LOCALAPPDATA=C:\Users\Administrator\AppData\Local LOGONSERVER=\\XT1-20140726YGA MFC_INC_PATH=C:\WinDDK\7600.16385.1\inc\mfc42 MFC_LIB_PATH=C:\WinDDK\7600.16385.1\lib\mfc\* MSC_OPTIMIZATION=/Od /Oi NEW_CRTS=1 NO_BINPLACE=TRUE NO_BROWSER_FILE=TRUE NTDBGFILES=1 NTDEBUG=ntsd NTDEBUGTYPE=both NTMAKEENV=C:\WinDDK\7600.16385.1\bin NUMBER_OF_PROCESSORS=4 OAK_INC_PATH=C:\WinDDK\7600.16385.1\inc\api OS=Windows_NT Path=C:\WinDDK\7600.16385.1\bin\amd64;C:\WinDDK\7600.16385.1\tools\sdv\bin;C:\WinDDK\7600.16385.1\bin\x86\oacr;C:\WinDDK\7600.16385.1\tools\pfd\bin\bin\x86;C:\WinDDK\7600.16385.1\tools\tracing\i386;C:\WinDDK\7600.16385.1\bin\x86;C:\WinDDK\7600.16385.1\bin\x86\x86;C:\WinDDK\7600.16385.1\bin\SelfSign;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PREFAST_VALID_IMPLIES_NOTNULL=1 PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=3a09 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PROJECT_ROOT=C:\WinDDK\7600.16385.1\src PROMPT=$P$G PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC=C:\Users\Public PUBLIC_ROOT=C:\WinDDK\7600.16385.1 PUBLISH_CMD=@echo Publish not available... RAZZLETOOLPATH=C:\WinDDK\7600.16385.1\Bin RCNOFONTMAP=1 SDK_INC_PATH=C:\WinDDK\7600.16385.1\inc\api SDK_LIB_DEST=C:\WinDDK\7600.16385.1\lib\wxp SDK_LIB_PATH=C:\WinDDK\7600.16385.1\lib\wxp\* SDV=C:\WinDDK\7600.16385.1\tools\sdv separate_object_root=FALSE SESSIONNAME=Console SUBSTITUTE_386_CC=C:\WinDDK\7600.16385.1\Bin\x86\oacr\oacrcl SUBSTITUTE_AMD64_CC=C:\WinDDK\7600.16385.1\Bin\x86\oacr\oacrcl SUBSTITUTE_CS_COMPILER_NAME=C:\WinDDK\7600.16385.1\BIN\x86\oacr\oacrcsc /nologo SUBSTITUTE_LINK=C:\WinDDK\7600.16385.1\Bin\x86\oacr\oacrlink SystemDrive=C: SystemRoot=C:\Windows TEMP=C:\Users\ADMINI~1\AppData\Local\Temp TMP=C:\Users\ADMINI~1\AppData\Local\Temp UMDF_INC_PATH=C:\WinDDK\7600.16385.1\inc\wdf\umdf USERDOMAIN=XT1-20140726YGA USERNAME=WinDDK USERPROFILE=C:\Users\Administrator USE_OBJECT_ROOT=1 VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\ VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\ WDM_INC_PATH=C:\WinDDK\7600.16385.1\inc\ddk windir=C:\Windows windows_tracing_flags=3 windows_tracing_logfile=C:\BVTBin\Tests\installpackage\csilogfile.log WPP_CONFIG_PATH=C:\WinDDK\7600.16385.1\bin\wppconfig _BUILDARCH=x86 _BuildType=chk _DFX_INSTALL_UNSIGNED_DRIVER=1 _IA32bit=true _NTDRIVE=C: _NTROOT=\WinDDK\7600.16385.1 _NT_TARGET_VERSION=0x501 _OACR_ERROR_LEVEL=0 _RunOacr=TRUE
举一反三:
① 启动一个默认的CMD命令行环境,执行“set >c:\1.txt”后,再开启VS2012的命令行提示编译环境,执行“set >c:\2.txt”,用文件比较工具比较两个文件的不同。这两个文件的不同,就是VS2012命令行编译环境做的特殊设置。
② 用同样的方式,可以查看WinCE5.0、Tornado2.2命令行编译设置的不同;
② 用同样的方式,查看Visual Studio之间做的设置环境变量区别:VC++6.0的设置环境变量位置一般在“C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin”下,为“VCVARS32.BAT”;VS2005,VS2008,VS2012分别在菜单下有命令行编译提示工具设置;