Think from getlasterror

xiaoxiao2021-03-05  22

GetLastError is a detected an error available by Microsoft. 1, I originally thought that getLastError is a process, but also worried that the error code is not accurate in a multi-threaded environment, because the correct execution code can also change the error code, but today I look at it, I found that getlasterror is a thread, error The code number is stored in the thread local memory, even if thread switching in a multi-thread environment does not change it. Oh, look at the book or carefully carefully.

2, getLastError gets the error code number, then use formatMessage to convert it to the corresponding error message, this is very good, but how many people use Microsoft's setLastError? When we write a program, more is to capture exceptions, then process, shield, although the value can be told the number of information by BOOL or other type of function returns. But once you can't process it, should we tell the caller, the corresponding error message? Don't say that the solution provided by Microsoft defines its own error message.

3. How is this function of the language provided by FormatMessage to determine the error message displayed by parameters? If the formatMessage is a Wineerror.h file, the error message in the file seems to be in English, can it have a precise translation mechanism? It is estimated that it should be a place where there are also related error messages in the OS. Note makelangid.

4, the local memory mechanism of thread allows us to enter "@ Err, HR" directly in the Watch window when using the VC debugger, but how much did I use?

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

New Post(0)