Common Return Types for Windows Functions

Data Type

Value to Indicate Failure

VOID

This function cannot possibly fail. Very few Windows functions have a return type of VOID.

BOOL

If the function fails, the return value is 0; otherwise, the return value is non-zero. Avoid testing 

the return value to see if it is TRUE: it is always best to test this return value to see if it is different from FALSE.

HANDLE

If the function fails, the return value is usually NULL; otherwise, the HANDLE identifies an object that you can 

manipulate. Be careful with this one because some functions return a handle value of INVALID_HANDLE_VALUE

which is defined as -1. The Platform SDK documentation for the function will clearly state whether the function returns 

NULL or INVALID_HANDLE_VALUE to indicate failure.

PVOID

If the function fails, the return value is NULL; otherwise, PVOID identifies the memory address of a data block.

LONG/DWORD

This is a tough one. Functions that return counts usually return a LONG or DWORD. If for some reason the function 

can't count the thing you want counted, the function usually returns 0 or -1 (depending on the function). 

If you are calling a function that returns a LONG/DWORD, please read the Platform SDK documentation carefully to 

ensure that you are properly checking for potential errors.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值