WINAPI和CALLBACK

int
WINAPI
WinMain(
 HINSTANCE hInstance,
 HINSTANCE hPrevInstance,
 LPSTR lpCmdLine,
 int nShowCmd
  );
《windows 程序设计》对WINAPI的解释为:
WINAPI识别字在WINDEF.H定义,语句如下:

#define WINAPI __stdcall
该语句指定了一个呼叫约定,包括如何生产机械码以在堆叠中放置函式呼叫的参数。许多Windows函式呼叫宣告为WINAPI。

由被调用的函数清理堆栈,所以参数自左向右入栈,生成的代码中函数名有一个_(下划线)做前缀,一个@和参数总的字节数(十进制)做后缀。它不支持可变参数,但它产生的代码比C的调用协定_cdecl短,因为没有每次调用后的清理堆栈的代码。

下面是MSDN上关于CALLBACK所做的说明:

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值