11th
October
2007
SetupDixxxx是windows提供的一套非常实用的应用层硬件信息查询API。为了更好地和界面融合起来,MFC的程序经常需要调用这些函数。但是包含这些函数的setupapi.h以及其他的一些guid的头文件需要包含一些基础的windows定义。
最容易想到的就是包含DDK的定义文件,因为这些函数出现在了DDK的文档中(当然也在MSDN中)。所以一上来就include了<ntddk.h>,这样就导致了很多redefinition的问题(和winnt.h冲突)。
其实这些函数在 C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\ 下也有一套,所以不用包含DDK那些头文件了。只要包含下面几个就可以了:
#include <windows.h>
#include <initguid.h> // Guid definition
#include <devguid.h>
#include <setupapi.h>
这里winnt.h还是不能替代windows.h,否则会出现CONST没定义等问题。
同时还要在Project setting中关掉 precompiled headers (stdafx.h)
posted in NT Kernel Study |
11th
October
2007
1. 提前后挥。特别是在running forehand的时候,跑的时候就要开始挥。
2. 前挥的timing。其实这个是最难掌握的,球速不同,timing自然不同。即使后挥了,但是timing不对,还是容易过早或者晚击球。
3.保持与球的距离。侧向距离要保持,特别是现在开始使用非over-size的球拍,对球的位置要求更高。 纵向距离要保持,主要体现在不要死站在距离底线很近的位置,适当退一步。
4. athletic height。这个经常忘记,如果能记住,尽量做到
5. 重心在右脚。这个是最近看球的时候发现的,如果到位的话,重心往右脚上一压,打出去的球自然很稳。但是这个要求每个球都很到位,不适合running forehand。
6.转身。还做得不够。
7. follow-through。
8. 动作幅度小。
恩,基本上就这些,打球的时候能够同时做到3到4样就不错了。
posted in Tennis |
6th
October
2007
有很多工具可以自动构建VS2005下的DDK编译环境。本着求实上进的精神,我还是自己照着一个sample 工程自己看了一下一些具体的设置。 主要就是设置一些DDK的头文件、library和一些诸如Entry Point/Base Address/SubSystem/Target Machine/Optimization方面的设置。 下面的设置是从一个win32 console工程的设置出发需要改动的地方。其中release版本中是一些区别于Debug版本的设置。
[Debug]
General/Output Directory: $(ConfigurationName)
C/C++
General/Additional Include Directories: \WINDDK\3790.1830\inc\crt;\WINDDK\3790.1830\inc\ddk\wxp;\WINDDK\3790.1830\inc\wxp;\WINDDK\3790.1830\inc\ddk\wdm\wxp;\WINDDK\3790.1830\src\network\inc;\WINDDK\3790.1830\INC\IFS\wxp
General/Debug Information Format:
Optimization/Enable Intrinsic Functions:
Preprocessor/Proprocessor Definitions: _DLL=1;_X86_=1;i386=1;STD_CALL;CONDITION_HANDLING=1;NT_INST=0;
WIN32=100;_NT1X_=100;WINNT=1;_WIN32_WINNT=0×0400;WIN32_LEAN_AND_MEAN=1;DEVL=1;DBG=1;FPO=0
Code Generation/Enable String Pooling: Yes (/GF)
Code Generation/Enable C++ Exceptions: No
Code Generation/Basic Runtime Checks: Default
Code Generation/Runtime Library: Multi-threaded (/MT)
Code Generation/Buffer Security Check: No (/GS-)
Code Generation/Enable Function-Level linking: Yes (/Gy)
Precompiled Headers/Precompiled Header File: .\$(ConfigurationName)/$(ProjectName).pch
Output Files/ASM List Location: .\$(ConfigurationName)/
Output Files/Object File Name: .\$(ConfigurationName)/
Output Files/Program Database File Name: .\$(ConfigurationName)\$(ProjectName).pdb
Advanced/Call Convention: __stdcall (/Gz)
Advanced/Compiled As: Default
Advancde/Force Includes: warning.h
Command Line(???): /Zel -cbstring /QIfdiv- /QIf
Linker
General/Output File: $(OutDir)\$(ProjectName).sys
General/Enable Incremental Linking: No (/INCREMENTAL:NO)
General/Additional Library Directories: \WINDDK\3790.1830\lib\wxp\i386;\WINDDK\3790.1830\lib\wxp
Input/Additional Dependency: ntoskrnl.lib hal.lib wmilib.lib ndis.lib $(NOINHERIT)
Input/Ignore All Default Libraries: Yes (/NODEFAULTLIB)
/*Input/Module Definition File: .\$(ProjectName).def*/
Debugging/Generate Program Database File: .\$(ConfigurationName)/$(ProjectName).pdb
System/SubSystem: Native (/SUBSYSTEM:NATIVE)
System/Stack Reserve Size: 262144
System/Stack Commit Size: 4096
Optimization/References: Eliminate Unreferenced Data (/OPT:REF)
Optimization/Enable COMDAT Folding: Remove Redundant COMDATs (/OPT:ICF)
Advanced/Entry Point: DriverEntry
Advanced/Set Checksum: Yes (/RELEASE)
Advanced/Base Address: 0×10000
Advanced/Merge Sections: .rdata=.text
Advanced/Target Machine: MachineX86 (/MACHINE:X86) / Not Set
Command Line: /ignore:4010,4037,4039,4065,4070,4078,4087,4089,4221,4210 /driver
[Release]
C/C++
General/Debug Information Format: Disabled
Optimization/Optimization: Full Optimization (/Ox)
Favor Size or Speed: Favor Small Code (/Os)
Linker
Debugging/Generate Map File: Yes (/MAP)
Debugging/Map File Name: $(Outdir)/$(ProjectName).map
Debugging/Map Exports: Yes (/MAPINFO:EXPORTS)
posted in NT Kernel Study |
2nd
October
2007
一个MFC的程序最近需要迁移到VS2005下面。折腾了半天,有几点需要总结一下,以后就不用再伤脑筋了:
1. 检查_UNICODE设置是否一致
2. 把所有用到的DLL和LIB都在VS2005下重新编译,生成新的LIB和DLL。LIB不匹配会出现LNK问题,DLL不匹配会出现 xxxx@class can’t be located in the DLL的错误。
3. 如果出现了LNK错误,首先检查lib的路径还有DLL是否都用的是新编译的版本(VS2005版本的)。如果没有继承CString类,基本不会出现ATL::CString模板的问题。Tip: 在Linker选项中加入/verbose:lib 来检查link的时候搜索路径是否正确,如果还在搜索VC98的目录,那基本上就是错误的原因了。
4. 著名的WM_HITTEST问题。UINT已经过时了,用LRESULT替代。
先想到这些,以后再补充。
posted in 编程珠玑 |