PeekMessage 和 GetMessage有什么区别?
new/delete 和 new[]/delete[]有什么区别
为什么dll中的函数要加 extern "C"
第一个问题:不知道
new[]/delete[]是删除数组用的,如:int *p=new int [5];delete []p;
dll 中的函数加extern "C"是为了使它可以在c语言里调用
因为C++默认会对函数名作一些处理使得C程序不能正常调用它
PeakMessage是检查消息队列中有没有消息,检查时,你可以删除其中的消息,也可以不删除
GetMessage则是从队列中取出消息,肯定会删除其中的消息的
Explain one by one:
PeekMessage 和 GetMessage有什么区别?
------------------------------------>
the difference lies in when your message handler is a time-consuming function.
If you use GetMessage() then your programe will block until your message handler
returns.During this time span ,you cant interact with your program.
PeekMessage provide a way to solve this problem by this:Whenever a message
comes,it supsend your time-consuming functions excuting and process the message.
So you could interact with your program.
new/delete 和 new[]/delete[]有什么区别
new[]/delete[] is the same with new/delete except that it is delete the
memory alloc for arrays!
while new/delete merely deals with a structure,new[]/delete[] deals with
arrays(could also be structure arrays)
为什么dll中的函数要加 extern "C"
when you create a MFC dll,the C++ compiler will add a extreme long name for
each of your export function.To avoid this,add extern "C" like this;
PeekMessage和GetMessage唯一的区别是:取得下一条消息之后,如果IDLE,是不是进行进程调度。
1、Unlike the GetMessage function, the PeekMessage function does not wait for a message to be placed in the queue before returning.
2、new/delete和new[]/delete[]都是内存操作,后者是用来分配数组的
3、DLL中加extern C是为了告诉编译器使用C风格生成编译后的函数符号名,不同的编译器对于C++函数编译之后的函数名是不同的,而DLL的目的是可以让别的程序调用,于是要求有一个统一的风格,SO,使用extern C