https://bugs.winehq.org/show_bug.cgi?id=51529
Bug ID: 51529 Summary: CloseHandle(INVALID_HANDLE_VALUE) returns FALSE, GetLastError is ERROR_INVALID_HANDLE Product: Wine Version: 5.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: sergey.bychkow@gmail.com Distribution: ---
Created attachment 70368 --> https://bugs.winehq.org/attachment.cgi?id=70368 Test CloseHandle(INVALID_HANDLE_VALUE)
CloseHandle(INVALID_HANDLE_VALUE) returns FALSE, GetLastError is ERROR_INVALID_HANDLE on Wine. I tried it with MacOSX and Linux.
But on Windows CloseHandle(INVALID_HANDLE_VALUE) returns TRUE. So many programs could fail if they didn't expect FALSE here.
Test case (Pascal). Can be compiled with FPC or Delphi.
// file TestCloseHandle.lpr
program TestCloseHandle;
{$APPTYPE CONSOLE}
uses //Winapi.Windows; Windows;
var aHandle: THandle; aResult: HRESULT; begin //aHandle := 0; aHandle := INVALID_HANDLE_VALUE;
if CloseHandle(aHandle) then aResult := 0 else aResult := GetLastError;
Writeln('Result: ', aResult); end.