Windows C/C++ 内存泄露检测
摘要:#pragma once #define _CRTDBG_MAP_ALLOC #include #include #include #include #include #include #include #include #ifdef _DEBUG #ifndef DBG_NEW #define DBG_NEW new(_NORMA...
阅读全文
posted @
2013-12-16 11:14
qinfengxiaoyue
阅读(254)
推荐(0)
回调机制
摘要:摘选.详情见:http://www.ibm.com/developerworks/cn/linux/l-callback/ 另见 Callback Functions Tutorial : http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557/Callback-Functions-Tutorial.htm 1 什么...
阅读全文
posted @
2013-11-22 15:02
qinfengxiaoyue
阅读(489)
推荐(0)
转:Windows版本判断大全
摘要:/*****************************************************************************Operating System Version PlatformIDWindows 8 6.2 VER_PLATFORM_WIN32_NT (=2)Windows 7 6.1 VER_PLATFORM_WIN32_NTWindows Serv...
阅读全文
posted @
2013-11-19 17:59
qinfengxiaoyue
阅读(4749)
推荐(0)
注册表的遍历和递归
摘要:1.遍历。用于查找某键(无子键)下面的所有值。以下示例了在Win7下查找所有设置了兼容性的程序: int CompatDetect(PCTSTR szAppName){ setlocale(LC_ALL,""); HKEY hk = NULL; LONG lRet=RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows ...
阅读全文
posted @
2013-11-19 10:29
qinfengxiaoyue
阅读(3637)
推荐(1)
Windows 消息框架: SDK教程
摘要:关键字:WindowsSDK 消息机制 http://www.codeproject.com/Articles/599/Windows-Message-Handling-Part-3 Handling Messages in SDK applications Windows Classes and Window Procedures DefWindowProc Sending Messa...
阅读全文
posted @
2013-10-22 23:32
qinfengxiaoyue
阅读(396)
推荐(0)
跨DLL边界传递CRT对象的隐患(或诸如:HEAP[]: Invalid Address specified to RtlValidateHeap(#,#)问题出现的原因)
摘要:Potential Errors Passing CRT Objects Across DLL Boundaries:http://msdn.microsoft.com/en-us/library/ms235460.aspx
阅读全文
posted @
2013-06-05 21:55
qinfengxiaoyue
阅读(585)
推荐(0)
HANDLE的无效值:NULL还是INVALID_HANDLE_VALUE? 以及对HANDLE的RAII封装
摘要:打开/创建一个HANDLE而忘记close的情况时有发生。利用RAII的思想,将HANDLE封装为一个类,在其析构函数中进行close,是一个不错 的方法。 ATL提供了一个CHandle类,但是提出了以下使用注意事项: Some API functions will use NULL as an empty or invalid handle, while others use INVAL...
阅读全文
posted @
2013-05-20 16:15
qinfengxiaoyue
阅读(16064)
推荐(0)
关于线程函数结束前显式调用_endthreadex
摘要:1. 本来,MSDN已经明确指出了: You can call _endthread or _endthreadex explicitly to terminate a thread; however, _endthread or _endthreadex is called automatically when the thread returns from the routine pas...
阅读全文
posted @
2013-05-18 01:09
qinfengxiaoyue
阅读(2373)
推荐(0)
使用FindFirstFile和FindNextFile对给定目录下所有文件进行广度优先遍历
摘要:bool FFBreadth(TCHAR *szPath)//输入只能以C:\xx或C:\xx\*为格式,不能以‘\’作为路径结尾。详见MSDN的FindFirstFile.{ if(_taccess(szPath,0)==-1) { cout<<"路径不存在"<<endl; return false; } wstring wsPath(szPath); if(wsPath.back()!=_...
阅读全文
posted @
2013-05-17 00:52
qinfengxiaoyue
阅读(733)
推荐(0)
工作线程的消息循环与通信
摘要:关键字:工作线程 消息循环 通信 同步 PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE); MsgWaitForMultipleObjectshttp://www.cppblog.com/qinqing1984/archive/2009/04/15/80038.html
阅读全文
posted @
2013-05-09 18:31
qinfengxiaoyue
阅读(259)
推荐(0)
从_tiddata看CRT的线程不安全函数
摘要://_tiddata的定义. CRT SRC\mtdll.hstruct _tiddata { unsigned long _tid; /* thread ID */ unsigned long _thandle; /* thread handle */ int _terrno; /* errno va...
阅读全文
posted @
2013-05-05 22:41
qinfengxiaoyue
阅读(1182)
推荐(0)
_endthreadex与CloseHandle
摘要:转自:http://bbs.csdn.net/topics/340008167CreateThread是系统API, _beginthreadex是CRT(CRunTimeLibrary运行时库)函数._beginthreadex内部会调用CreateThread函数。_endthreadex会释放_beginthreadex为tiddata结构分配的内存。如果线程函数中调用了CRT函数(注:不是全部CRT函数 只是其中一部分函数),则该线程函数必须由_beginthreadex而不是CreateThread函数创建。否则会产生内存泄露。如果在除主线程之外的任何线程中进行一下操作,你就应该使用
阅读全文
posted @
2013-04-28 00:20
qinfengxiaoyue
阅读(3476)
推荐(0)
MFC非模态对话框的销毁
摘要:转自:http://www.cnblogs.com/afarmer/archive/2012/03/31/2427328.html,节选。非模态对话框相对于模态对话框,其创建和销毁过程和模态对话框有一定的区别 。先看一下MSDN的原文:When you implement a modeless dialog box, always override the OnCancel member function and call DestroyWindow from within it. Don’t call the base class CDialog::OnCancel, because it
阅读全文
posted @
2013-04-27 17:49
qinfengxiaoyue
阅读(1649)
推荐(0)
关于消息循环的深入分析
摘要:关键字:MFC/WTL/ATL Message-loop PretranslateMessge IsDialogMessgehttp://www.cnblogs.com/Greatest/archive/2009/08/25/1553623.html
阅读全文
posted @
2013-04-27 16:46
qinfengxiaoyue
阅读(194)
推荐(0)
MSDN关于消息和消息队列的详细解析
摘要:About Messages and Message Queues:http://msdn.microsoft.com/en-us/library/ms644927(v=vs.85).aspx#filtering简要如下:This section discusses the following topics:Windows MessagesMessage TypesSystem-Defined MessagesApplication-Defined MessagesMessage RoutingQueued MessagesNonqueued MessagesMessage HandlingM
阅读全文
posted @
2013-04-25 23:44
qinfengxiaoyue
阅读(319)
推荐(0)
Windows对象分类:用户对象、GDI对象、核心对象
摘要:Object Categories : http://msdn.microsoft.com/en-us/library/ms724515(v=vs.85).aspx
阅读全文
posted @
2013-04-25 11:48
qinfengxiaoyue
阅读(737)
推荐(0)
CRT Debugging Techniques / Finding Memory Leaks Using the CRT Library
摘要:关键字:C/C++ CRTDebugging 内存泄露 检测CRT Debugging Techniques :http://msdn.microsoft.com/en-us/library/zh712wwf.aspxFinding Memory Leaks Using the CRT Library : http://msdn.microsoft.com/en-us/library/x98tx3cf.aspx
阅读全文
posted @
2013-04-24 11:58
qinfengxiaoyue
阅读(166)
推荐(0)
_beginthread和CreateThread
摘要:转自:http://www.cnblogs.com/project/archive/2011/08/21/2147634.html 为什么要用C运行时库的_beginthreadex代替操作系统的CreateThread来创建线程? 来源自自1999年7月MSJ杂志的《Win32 Q&A》栏目 你也许会说我一直用CreateThread来创建线程,一直都工作得好好的,为什么要用_b...
阅读全文
posted @
2013-04-20 21:29
qinfengxiaoyue
阅读(594)
推荐(0)
MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
摘要:以vs2012为标准。转自:http://technet.microsoft.com/zh-cn/library/w4zd66ye ,有改动。 一 MFC的静态库(.lib) MFC静态库使用下列命名约定: uAFXcWd.LIB . 库命名约定的说明符如下: 说明符 值和含义 u (n) ANSI...
阅读全文
posted @
2013-02-20 21:59
qinfengxiaoyue
阅读(6119)
推荐(0)
MFC的运行及消息机制(一):从一个空项目开始编写MFC程序
摘要:对比传统的Win32 API编程,MFC封装了很多东西;而AppWizard的使用,更是隐藏了很多过程。这样使得我们对MFC程序的运行的过程顺序、关系、细节把握不清,难以进行高质量的程序编写。 要想较好的把握MFC,主要的问题有三个方面: 1.对Win32 API编程及Windows平台的基本机制有一定认识(消息队列和消息分类) 2.对程序的编译、链接、装载、库等方面有一定认识 3.对C+...
阅读全文
posted @
2013-02-18 18:24
qinfengxiaoyue
阅读(5468)
推荐(0)