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. |
Common Return Types for Windows Functions
最新推荐文章于 2023-08-13 00:53:05 发布