https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.getlastwin32error?view=net-10.0&redirectedfrom=MSDN
Marshal.GetLastWin32Error Method (System.Runtime.InteropServices) | Microsoft Learn
Returns the error code returned by the last unmanaged function that was called using platform invoke that has the SetLastError flag set.
marshalmethodsystemruntimemicrosoft