用bool而不要用BOOL,bool是8位BOOL是16位long是16位,所以COM会把BOOL看成bool.
在MFC中你可能经常用BOOL,但在COM中最好别用它,BOOL不是COM规范的数据类型.
在MFC中你可能经常用BOOL,但在COM中最好别用它,BOOL不是COM规范的数据类型.
解决方案 »
- 两个edit数组相乘问题
- ReBar是标准控件还是WTL的控件,WindowsXP本身有这个控件吗?
- 烦人问题,关于所做动态库用C#调用和MFC程序调用的差别
- 请问,可不可以动态改变一个窗口的样式为WS_CHILD或WS_POPUP??
- CButton派生问题
- 在哪能下到msdn2004?
- 关于VC编译不能完成的问题
- 用vc写html,已经写的有点变态(请上帝原谅),具体内容见内
- 请教双屏显示怎么实现!
- !挑战!编写单片机器件仿真DLL,用世界最先进的仿真SDK!
- 这个怎么做啊!
- 哪位大虾熟悉DirectDraw,我用DirectDraw来显示一帧帧的图象,图象总在最前端,有办法使它属于某个子窗口吗?让它不处于最前端?
所以vc的bool=vc的int=vb的long
看来programan (金蛇郎君) 还没有把vc和vb融为一体
顺便说一下BOOL和bool的小插曲:
在VC4.2的时候,bool被typedef成了int,既在win32平台下占32位内存。这显然是太浪费了,一种只有两种状态的变量居然占了32位内存。
在VC5.0后,bool被定义成了一个字节即8位,制止了这种浪费。但以前用VC4.2时编译成的OBJ文件中bool已经占了32位。为了兼容过去而诞生了BOOL,BOOL等于VC4.2的bool。
当我们拿到了VC4.2的dll,lib和头文件时,第一件事就是把老的头文件中所有的bool替换成BOOL。
以下摘自msdn:
In Visual C++4.2, the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0 and later, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the same call yields 1. This can cause memory corruption problems if you have defined structure members of type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or DLLs built with the 4.2 and 5.0 or later compilers.