Is there a way to check if the descriptor in my case really returned by CreateFile?
The problem I am facing is that the correct file descriptor returned by CreateFile (this is not INVALID_HANDLE_VALUE) later causes a WriteFile error, and GetLastError claims this is due to an invalid descriptor.
Since it seems that you are not setting the descriptor value to INVALID_HANDLE_VALUEafter closing it, I would do to set the reading observation point in a variable HANDLE, which will cause the debugger to break into every line that refers to the value HANDLE. You will be able to see the order in which the variable is available, including when reading a variable to pass it to CloseHandle.
INVALID_HANDLE_VALUE
HANDLE
CloseHandle
See: Adding a watchpoint (violation when changing a variable)
Checking the correctness of the handle at best is a strip.
- , ( ), , , .
, , , , .
.
, HANDLE , ( , , GDI ..), Windows API GetFileInformationByHandle.
, , ReadFile WriteFile nNumberOfBytesToWrite, 0.
nNumberOfBytesToWrite
Open-File , , - , INVALID_HANDLE. , -?
, , :
, INVALID_HANDLE_VALUE , - . - - . .
(1) - , ( )
, , , CreateFile. IIRC, INVALID_HANDLE_VALUE , GetLastError, , .
CreateFile
GetLastError
Source: https://habr.com/ru/post/1783593/More articles:возможно ли изменить текст кнопки выбора в фотоальбоме iphone? - iphonejquery datepicker not picking date? Conflict? - jqueryreintegrate workflow - svnMEF: GetExportedValue from type? - c #PHP / MYSQL Chat AJAX - ajaxHow to reject a modal view controller from UITabBarController - iphoneReturning an object with an unbiased memory stream causes a memory leak? - c #Automatically generated identifiers for facelets components - javaAuthorization Error Using Google Code and TortoiseSVN - authenticationStrong coupling between stages in gherkin specifications - cucumberAll Articles