call back函数实际是回调函数,他实际上可以是用户自己定义的函数,具有用户希望和需要的功能,当函数完成时,函数将返回一个用户预先定义的值,其实也就是自己设置的函数,这是我自己理解的,不知道对不对,希望大家赐教!

解决方案 »

  1.   

    A callback function is essentially an event handler that is implemented by an application and called by the system. Microsoft® Windows® applications typically implement multiple callback functions, each one designed for a particular set of events. When an event occurs, the system notifies the application by calling the appropriate callback function. The callback function also usually has a parameter list that the system can use to pass the application more detailed information about the event. The most common example of a callback function is the window procedure. This function is used by the system to pass Windows messages to the applications that owns the window. 
      

  2.   

       Call back是一种事件处理机制,比如说Windows程序的MainProc(),当某些事件发生时,系统调用程序的MainProc(),通知程序发生了什么事,而具体如何处理,完全由你在MainProc决定。
       通样比如一些枚举函数也是通过CallBack实现的,比如枚举文件,系统只是告诉你找到了要找的文件这个事件,而如何处理完全有你的CallBack函数决定啊。
      

  3.   

    CALLBACK函数之所以成为CALLBACK,其原因就在于,这种函数是由程序员提供,但对它的调用却是由系统负责,程序中不会显式的调用它(当然,你硬要调用,也可以)。比如最常见的窗口过程WindowProc,你辛辛苦苦写了半天,却发现,咦,我怎么程序中根本没调用过这个函数?!其实你在窗口类中已经把它告诉系统了,系统会调用。正因为如此,CALLBACK函数就必须遵守系统的调用约定,而不能像普通函数那样可以使用C调用规则,也可以使用pascal规则。CALLBACK这个宏就是为了实现这个约定——所有的回调函数都应用CALLBACK来修饰。Win16中,CALLBACK就是far pascal,Win32中,CALLBACK就是stdcall。Windows因为是事件驱动的,因此会大量地用到CALLBACK函数。不过话说回来,CALLBACK也只不过是遵守某种调用规则的函数而已,因此不一定只能被系统调用,如果需要,程序中也完全可以直接调用——它不见得就比别的函数特殊。