Returns the HRESULT corresponding to the last error incurred by Win32 code executed using Marshal.
[Visual Basic] Public Shared Function GetHRForLastWin32Error() As Integer [C#] public static int GetHRForLastWin32Error(); [C++] public: static int GetHRForLastWin32Error(); [JScript] public static function GetHRForLastWin32Error() : int;
The HRESULT corresponding to the last Win32 error code.
The target function must have had the setLastError metadata flag set. For example, the SetLastError field of the System.Runtime.InteropServices.DllImportAttribute must be true. The process for this varies depending upon the source language used: C# and C++ are false by default, but the Declare statement in Visual Basic is true.
Note This method uses SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass user input to Marshal class methods without validation. For important limitations on using the LinkDemand member, see Demand vs. LinkDemand.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- SecurityPermission for operating with unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.