
C/C++
文章平均质量分 69
HoNooD
这个作者很懒,什么都没留下…
展开
-
MFC应用程序中处理消息,创建窗口的过程,关闭窗口(非模态窗口),打开模式对话框等的函数调用顺序
<br /><br />· MFC应用程序中处理消息的顺序<br />· MFC应用程序创建窗口的过程<br />· MFC应用程序关闭窗口的顺序(非模态窗口)<br />· MFC应用程序中打开模式对话框的函数调用顺序<br />· MFC应用程序中关闭模式对话框的顺序<br />· 打开无模式对话框的顺序<br /> <br /> <br />MFC应用程序中处理消息的顺序<br />1. AfxWndProc()<br />该函数负责接收消息,找到消息所属的CWnd转载 2010-10-25 23:16:00 · 3634 阅读 · 2 评论 -
Designated Initializers
<br />6.26 Designated Initializers<br />Standard C90 requires the elements of an initializer to appear in a fixed order, the same as the order of the elements in the array or structure being initialized.<br />In ISO C99 you can give the elements in any ord转载 2010-12-19 21:26:00 · 1618 阅读 · 2 评论 -
后自增(减)的结果不是左值
<br />#include <cstdio> int main(){ int foo = 5; void* p = NULL; printf_s("Address of foo is 0x%p. /r/n", &foo); // 0x0012FF60 p = &(++foo); printf_s("Address of ++foo is 0x%p. /r/n", p); // 0x0012FF60 p =原创 2010-12-31 19:02:00 · 1133 阅读 · 0 评论 -
巴科斯-诺尔范式
<br />巴科斯-诺尔范式(也称为巴科斯-瑙尔范式、巴克斯-诺尔范式),即 BNF,是一种用于表示上下文无关文法的语言,上下文无关文法描述了一类形式语言。它是由约翰·巴科斯(John Backus)和彼得·诺尔(Peter Naur)首先引入的用来描述计算机语言语法的符号集。<br />尽管巴科斯范式也能表示一部分自然语言的语法,它还是更广泛地使用于程序设计语言、指令集、通信协议的语法表示中。大多数程序设计语言或者形式语义方面的 教科书都采用巴科斯范式。在各种文献中还存在巴科斯范式的一些变体,如扩展巴科斯转载 2011-01-11 10:46:00 · 2459 阅读 · 0 评论 -
虚拟单一继承下基类和派生类起始地址不同
<br />虚拟单一继承下基类和派生类起始地址不同. <br />// VC++2005#include <stdio.h> class Base{}; class Derived: public Base{}; class VirtualDerived: virtual public Base{}; int main() { Base* pB = NULL; Derived* pD = new Derived;原创 2011-05-18 19:48:00 · 1044 阅读 · 0 评论 -
多重继承下, 执行期 this 指针的调整示例代码
<br />// VC++ 2005 #include <stdio.h> class A{public: A() { printf(">> 在类 A 的 constructor 中, this 的值是 0x%p./n", this); } virtual ~A() { printf("<< 在类 A 的 virtual destructor 中, this 的值是 0x%p./n", this)原创 2011-05-18 14:59:00 · 1017 阅读 · 0 评论 -
POD 类型
<br />http://www.fnal.gov/docs/working-groups/fpcltf/Pkg/ISOcxx/doc/POD.html<br />C++ Language Note:<br />POD Types<br />Walter E. Brown<br />September 29, 1999; last updated November 29,1999<br />1. Purpose<br />Thisnote documents the definition of a原创 2011-05-19 17:37:00 · 1799 阅读 · 0 评论 -
指向 Data Member / Member Function 的指针的类型
<br />这个用得少,总忘。<br />// VC++ 2005 /Gd class Foo{public: void __thiscall f_thiscall(){} // 注: VC++ 2005 以前, 程序员不能显式使用 // __thiscall. 因为 __thiscall 还不是 // 关键字.原创 2011-05-20 21:02:00 · 1446 阅读 · 0 评论 -
Segment/Section/Virtual Memory/Page之间的区别
<br />对于 Segment, Section, Virtual Memory, Page 这些词我们肯定不会陌生. 但在阅读一些书籍和文章的时候, 不知是那些作者的缘故还是自己的原因, 我们不能正确区分他们之间的区别. 我不得不承认, 真要 100% 弄清楚这些概念并不是一件容易的事情, 因为它们涉及到很多不同方面的内容 (例如编译/连接, 汇编, 操作系统等) , 同时这些内容本身就不太容易掌握. 但是我想写这篇文章, 一方面是为了总结我对这些内容的分析和理解, 另一方面在以后的学习中我可以对这篇文转载 2010-12-16 13:21:00 · 3541 阅读 · 1 评论 -
HeapAlloc 和 GlobalAlloc 以及 VirtualAlloc 三者之间的关系
<br />该文章系转载, 出处不详, 仅具参考价值. <br /><br />VirtualAlloc 一次分配 1PAGE 以上的 RAM. 每次分配都是 PAGE 的整数倍. 你不会想为了分配 1 个 BYTE 的空间而浪费剩下的 4095 字节. OK, 你可以自己写算法, 多分配几 PAGE. 然后每次分配少量数据时就从那几 PAGE 中划分出来. KERNEL32 提供了一个解决办法, 用 HeapAlloc/GlobalAlloc 分配 RAM. 这样, KERNEL32 帮助完成分配动作,转载 2010-12-15 14:17:00 · 7053 阅读 · 0 评论 -
C++ 变长参数列表函数的用法
<br />对变长参数的访问是通过下面三个宏实现的:<br />void va_start( va_list arg_ptr, prev_param ); // (ANSI version) type va_arg( va_list arg_ptr, type ); void va_end( va_list arg_ptr ); <br />参数 <br />type: 待获取参数的数据类型; <br />arg_ptr: 指向参数列原创 2010-09-26 23:48:00 · 6905 阅读 · 0 评论 -
格式化的消息框
<br />MessageBoxPrintf 函数的实现. <br />// Build with VS2008withSP1, /W4#include <windows.h> #include <tchar.h> #include <cstdio> #include <cstdarg> int CDECL MessageBoxPrintf(TCHAR* szCaption, TCHAR* szFormat, ...){ TCHAR* pBuffer(NULL)原创 2010-09-27 01:10:00 · 1700 阅读 · 0 评论 -
Synchronization Functions
<br />The following functions are used in synchronization.<br />Asynchronous functionDescriptionAPCProcAn application-defined callback function used with the QueueUserAPC function.GetOverlappedResultRetrieves the results of an overlapped operation.QueueUse转载 2010-09-28 10:13:00 · 1126 阅读 · 0 评论 -
剖析VC++函数调用约定
<br />Visual C/C++ 的编译器提供了几种函数调用约定,了解这些函数调用约定的含义及它们之间的区别可以帮助我们更好地调试程序。在这篇文章里,我就和大家共同探讨一些关于函数调用约定的内容。<br /> Visual C/C++ 的编译器支持如下的函数调用约定:<br /> <br />关键字<br />清理堆栈<br />参数入栈顺序<br />函数名称修饰(C)<br />__cdecl<br />调用函数<br />右 à左<br />_函数名<br />__stdcall<br /转载 2010-09-28 13:18:00 · 970 阅读 · 0 评论 -
Virtual-Key Codes
<br />Virtual-Key CodesConstantValueDescriptionVK_LBUTTON0x01Left mouse buttonVK_RBUTTON0x02Right mouse buttonVK_CANCEL0x03Control-break processingVK_MBUTTON0x04Middle mouse button (three-button mouse)VK_XBUTTON10x05X1 mouse buttonVK_XBUTTON20x06X2 mouse b原创 2010-10-09 21:39:00 · 1926 阅读 · 0 评论 -
Viewing Decorated Names
<br />You can get the decorated form of a function name after you compile the source file that contains the function definition or prototype. To examine decorated names in your program, you can do one of the following:<br />Use a listing<br />Use the DUMPB转载 2010-10-11 21:58:00 · 771 阅读 · 0 评论 -
Policies/Binary Compatibility Issues With C++
<br />Definition<br />A library is binary compatible, if a program linked dynamically to a former version of the library continues running with newer versions of the library without the need to recompile.<br />If a program needs to be recompiled to run wit转载 2010-12-05 22:57:00 · 911 阅读 · 0 评论 -
Security Considerations: International Features
<br />This topic provides information about security considerations related to International Support features. You can use it as a starting point and then see the documentation for the international technology of interest for technology-specific security c转载 2010-10-17 23:10:00 · 1062 阅读 · 0 评论 -
多重继承内存布局分析
<br />// VC++ 2005 /Gd // acronym(Root Level) = RL // acronym(Second Level) = SL // acronym(Third Level) = TL #include <stdio.h> typedef void (*VFuncPtr)(); typedef VFuncPtr* VTable; class RL1 {public: virtual void vf原创 2011-05-21 22:04:00 · 873 阅读 · 0 评论 -
VC++ 2005 编译器 Data Member 的布局
<br />《深度探索C++对象模型》P.92 L.18:<br />C++ Standard 要求,在同一个 access section(也就是 private、public、protected 等区段)中,member 的排列只需符合“较晚出现的 member 在 class object 中有较高的地址”这一条件即可。也就是说,各个 member 并不一定得连续排列。(注:最后这句与本文内容无关)<br />而书上某个地方说 C++ 标准对各个 access section 的 member 并没有原创 2011-05-22 20:23:00 · 1986 阅读 · 0 评论 -
自旋锁和信号量
自旋锁自旋锁是专为防止多处理器并发而引入的一种锁,它应用于中断处理等部分。对于单处理器来说,防止中断处理中的并发可简单采用关闭中断的方式,不需要自旋锁。自旋锁最多只能被一个内核任务持有,如果一个内核任务试图请求一个已经被持有的自旋锁,那么这个任务就会一直进行忙循环——旋转转载 2011-08-15 01:24:12 · 2128 阅读 · 0 评论 -
gSOAP 快速使用步骤
用 WebXml 提供的“腾讯QQ在线状态 WEB 服务”做示范。Web 服务链接如下:Endpoint: http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmxDisco : http:/原创 2011-08-30 18:44:33 · 4466 阅读 · 0 评论 -
用 Windows API 创建和编辑 .ini 文件
1. 与 .ini 文件相关的 API 有两类:1)操作系统配置文件 Win.ini 的函数GetProfileSectionGetProfileStringGetProfileIntWriteProfileSectionWriteProfileString2)操原创 2011-10-10 18:12:38 · 6097 阅读 · 1 评论 -
MFC 的 Picture Control 加载 BMP/PNG 图片的方法
1. 加载 BMPCStatic* pWnd = (CStatic*)GetDlgItem(IDC_PIC); // 得到 Picture Control 句柄pWnd->ModifyStyle(0, SS_BITMAP); // 修改它的属性为位图pWnd->SetBi原创 2011-10-09 10:56:58 · 46995 阅读 · 4 评论 -
为什么通过空指针(NULL)可以正确调用一些类的成员函数?
原文:http://blog.youkuaiyun.com/starlee/article/details/2062586有下面的一个简单的类:class CNullPointCall{public: static void Test1(); void Test2(); void Test3(int iTest); void Test4();转载 2011-11-27 20:02:28 · 6025 阅读 · 0 评论 -
双指针函数参数什么时候需要加 const,什么时候不能加?
我的理解是:如果函数的目的是修改输入参数代表的指针的值,则加 const 更安全;如果函数的目的是为了修改输入字符数组的内容,就不能加 const。测试代码:#include #include void parameter_no_qualifier_const_is_to_modify_chararray_contents(char** p_array);void test__par原创 2012-01-09 20:56:00 · 4120 阅读 · 0 评论 -
.dll 的搜索顺序
《Windows 核心编程(第5版)》P522 19.2.3 运行可执行模块:由于导入段只包含 DLL 的名称,不包含 DLL 的路径,因此加载程序必须在用户的磁盘上搜索 DLL。下面是加载程序的搜索顺序:(1) 包含可执行文件的路径;(2) Windows 的系原创 2010-07-06 00:12:00 · 3301 阅读 · 6 评论 -
VC manifest
从 VS2005 开始,微软在 VC 的编译选项中添加了manifest (中文) 这个功能,这将有助于软件以Side-by-side 方式运行。采用 /MD 和 /MDd 运行时库选项的项目 manifest 是必要的。当程序启动时发生类似下图找不到 MSVCRxx转载 2011-08-12 16:20:08 · 2796 阅读 · 0 评论 -
继承体系中 destructor 的执行次序
<br />《深度探索C++对象模型》P.233 L.-2: <br />一个由程序员定义的 destructor 被扩展的方式类似 constructor 被扩展的方式,但顺序相反:<br />1. 如果 object 内带一个 vptr,那么首先重设 (reset) 相关的 virtual table;<br /> If the object contains a vptr, it is reset to the virtual table associated with the class.<b原创 2011-05-23 20:01:00 · 1439 阅读 · 1 评论 -
if ( yy == xx.getValue() ) 编译器扩展模拟代码
<br />《深度探索C++对象模型》P.239 中间部分伪码模拟:<br />// VC++ 2005 #include <stdio.h> class X; class Y; extern X g_x; extern Y g_y; class Y{public: Y() { printf("Y's default constructor/n"); } Y(Y const&) {原创 2011-05-23 21:25:00 · 1001 阅读 · 0 评论 -
C语言字节对齐详解
<br />一、什么是对齐,以及为什么要对齐:<br />1. 现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定变量的时候经常在特定的内存地址访问,这就需要各类型数据按照一定的规则在空间上排列,而不是顺序的一个接一个的排放,这就是对齐。<br />2. 对齐的作用和原因:各个硬件平台对存储空间的处理上有很大的不同。一些平台对某些特定类型的数据只能从某些特定地址开始存取。其他平台可能没有这种情况, 但是最常见的是如果不按照适合其转载 2011-06-01 19:22:00 · 676 阅读 · 0 评论 -
又是类的 "构造函数", "拷贝构造函数" 和 "赋值操作符"
<br />// -------------------------------------------------------------------[代码]----#include "iostream" // 这里不使用"尖括号"是因为 HTML 会认为它是 tag. class Foo{public: Foo() { std::cout << "Foo's default-constructor is running." << std:原创 2011-04-28 13:12:00 · 790 阅读 · 0 评论 -
代名符
在 C++ 语言编程设计中常利用 #define 语句定义一类空的字符串代换技术, 被称为代名符定义.代名符在程序中不起任何实际作用, 只能放在行首用来说明程序的设计者, 类的归属, 设计时间, 程序的分类或所处的总体位置等, 有助于读程序的信息. 如下所示: #define TEST TEST void main(){ // ...} 另一个例子,原创 2011-06-24 13:40:00 · 1125 阅读 · 0 评论 -
Windows 消息机制要点
链接:http://developer.51cto.com/art/200708/54695.htm 系统将会维护一个或多个消息队列, 所有产生的消息都会被放入或是插入队列中. 系统会在队列中取出每一条消息,根据消息的接收句柄而将该消息发送给拥有该窗口的程序的消息循环. 1. 窗转载 2011-07-26 14:18:40 · 1929 阅读 · 0 评论 -
GetProcAddress 使用注意事项
使用 GetProcAddress Function 时,有以下几点需要特别留意:1. 第二个参数类型是 LPCSTR,不是 LPCTSTR;2. 用 __declspec(dllexport),按 C 名称修饰(extern "C") 导出的函数名,对于 __std原创 2011-08-12 09:08:38 · 27893 阅读 · 0 评论 -
VC运行时库
Reusable Library Switch Library Macro(s) Defined----------------------------------------------------------------Single Th转载 2011-08-12 15:48:50 · 2827 阅读 · 1 评论 -
Time Management
<br />Use these functions to get the current time and convert, adjust, and store it as necessary. The current time is the system time.<br />The _ftime and localtime routines use the TZ environment variable. If TZ is not set, the run-time library attempts t原创 2010-09-26 00:50:00 · 1128 阅读 · 0 评论 -
Using dllimport and dllexport in C++ Classes
<br />Microsoft Specific <br />You can declare C++ classes with the dllimport or dllexport attribute. These forms imply that the entire class is imported or exported. Classes exported this way are called exportable classes.<br />The following example defin转载 2010-09-21 15:48:00 · 853 阅读 · 0 评论 -
获取字符串长度
字符串的长度通常是指字符串中包含字符的数目,但有时需要的是字符串所占字节的数目。常见的获取字符串长度的方法如下:sizeof:获取字符数组的字节数(包括结束符0);对于ANSI字符串和UNICODE字符串,形式如下: sizeof(cs) / sizeof(char) sizeof(ws) / sizeof(wchar_t)对于MBCS无效。strlen() / wcs原创 2009-12-08 09:00:00 · 2208 阅读 · 0 评论 -
C++ 异常说明/规范
1. 概念 异常说明/规范(exception specification)指定, 如果函数抛出异常, 被抛出的异常将是包含在该说明中的一种, 或者是从列出的异常中派生的类型. 2. 定义 异常说明跟在函数形参表之后. 一个异常说明在关键字throw之后跟着一个(可能为空的)由圆括号括起来的异常类型列表. 如: void foo(int) throw (std::l原创 2009-12-08 15:22:00 · 1978 阅读 · 0 评论