"Windows Core Programming" Reading Notes (1)

xiaoxiao2021-03-06  74

The first part of the programmer must read

Chapter 1 Processing Procedure Wrong

(1) Return to the common Windows function: Void: No return value, the function is not possible to fail. The Windows function rarely this type bool: The function is running to return 0, otherwise it returns 0Handle: Failback Returns NULL, otherwise returns an operable object of Handle. Note: Some functions return a handle value invalid_handle_value, which is defined as -1. The function's Platform? SDK document will clearly explain that the function is returned when the function is failed. The function is still invalid_handle_validpvoid: The return value is NULL, otherwise returns PVOID to identify the memory address of the data block LONG / DWORD: this is a It is difficult to handle the value. Return number of functions usually returns LONGDWORD. If for some reason, the function does not count the object you want to count, then the function is usually returned to 0 or -1 (depending on the function). If the called function returns long / dword, please read the Platform SDK document carefully to make sure it is correct? Check a potential error.

(2) When a Windows function is running an error, you can obtain a 32-bit error code that calls the associated thread that calls the function by calling the Dword GetLast Error () function. Its specific error text is stored in a list of Winerror.h header files, and when debugging in the VC, you can also get the run error code and specific error text of the called function by typing "@ Err, HR" at the Watch window. . (3) Windows also provides a function that converts the error code into its text description. This function is called FormatMessage, the format of this function is as follows: DWORD FORMATMESSAGE (DWORD DWFLAGS, LPCVOID PSOURCE, DWORD DWMESAGEID, DWORD DWLANGUAGE, PTSTR PSZBuffer, DWORD NSIZE, VA_LIST * Argument);

November 8, 2004

转载请注明原文地址:https://www.9cbs.com/read-93896.html

New Post(0)