有人能说说CALLBACK吗?

hhjdk967 2004-07-16 05:25:26
还有在CALLBACK定义的函数下各种变量是怎么定义避免错误?
...全文
135 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjdbear 2004-07-17
  • 打赏
  • 举报
回复
楼主,我们的名字有三个字母是一样的,巧了!!!
RockHwnd 2004-07-17
  • 打赏
  • 举报
回复
关注一下
名牌大灰狼 2004-07-16
  • 打赏
  • 举报
回复
大家还是听MS说
callback

The [callback] attribute declares a static callback function that exists on the client side of the distributed application. Callback functions provide a way for the server to execute code on the client.


[callback [ , function-attr-list] ] type-specifier [ptr-declarator] function-name(
[ [attribute-list] ] type-specifier [declarator]
, ...);
Parameters
function-attr-list
Specifies zero or more attributes that apply to the function. Valid function attributes are [local]; the pointer attribute [ref], [unique], or [ptr]; and the usage attributes [string], [ignore], and [context_handle]. Separate multiple attributes with commas.
type-specifier
Specifies a base_type, struct, union, enum type, or type identifier. An optional storage specification can precede type-specifier.
ptr-declarator
Specifies zero or more pointer declarators. A pointer declarator is the same as the pointer declarator used in C; it is constructed from the * designator, modifiers such as far, and the qualifier const.
function-name
Specifies the name of the remote procedure.
attribute-list
Specifies zero or more directional attributes, field attributes, usage attributes, and pointer attributes appropriate for the specified parameter type. Separate multiple attributes with commas.
declarator
Specifies a standard C declarator such as identifiers, pointer declarators, and array declarators. For more information, see Array and Sized-Pointer Attributes, arrays, and Arrays and Pointers. The parameter-name identifier is optional.
Return Values
This control code's function has no return values.
Remarks
The [callback] function is useful when the server must obtain information from the client. If server applications were supported on Windows 3.x, the server could make a call to a remote procedure on the Windows 3.x server to obtain the needed information. The callback function accomplishes the same purpose and lets the server query the client for information in the context of the original call.

Callbacks are special cases of remote calls that execute as part of a single thread. A callback is issued in the context of a remote call. Any remote procedure defined as part of the same interface as the static callback function can call the callback function.

The RpcCancelThread function cannot be used to cancel a call that may dispatch a static callback. If a particular remote procedure call will never result in a callback, then it can be canceled. Otherwise, a call can be canceled only if it can be guaranteed that a callback for it has not been issued.

Only the connection-oriented and local-protocol sequences support the callback attribute. The size of the [out] data for callbacks over the local-protocol sequence is limited to 150 bytes. If an RPC interface uses a connectionless (datagram) protocol sequence, calls to procedures with the callback attribute will fail.

Handles cannot be used as parameters in callback functions. Because callbacks always execute in the context of a call, the binding handle used by the client to make the call to the server is also used as the binding handle from the server to the client.

Callbacks can nest to any depth.

Example Code

[callback] HRESULT DisplayString([in, string] char * p1);

See Also
arrays, MIDL Base Types, const, context_handle, enum, Interface Definition (IDL) File, ignore, local, /osf, ref, ptr, string, struct, union, unique, RpcCancelThread

windyloft 2004-07-16
  • 打赏
  • 举报
回复
你指定回调函数作为某个函数的参数,这个函数会被那个函数调用,例如
...
EnumChildWindows(hWnd,EnumChildProc,NULL);
...

BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
{
// handle your code here
GetWindowText(hwndChild,buf,bufsize);
return TRUE;
}

EnumChildWindows的第二个参数就是个函数指针,这个函数会被EnumChildWindows调用,但你不知道它何时调用,
代码中传入是定义好的EnumChildProc这个函数,如何控制这个回调函数行为就是你的事情了,这里的代码是获取每个子窗口的标题
windyloft 2004-07-16
  • 打赏
  • 举报
回复
CALLBACK函数就是在你的程序里被WINDOWS挑用的函数,一般情况下是我们通过调用WINDOWS的函数里编写程序
lcxf 2004-07-16
  • 打赏
  • 举报
回复
一言难尽的话题!

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧