Created
December 28, 2023 18:12
-
-
Save Leo40Git/4d7bc5afc8043ce8d8b217d5def21294 to your computer and use it in GitHub Desktop.
MAKE_HRESULT_FROM_WIN32 as a PowerShell function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Make-HRESULT-From-Win32 { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[long] $ErrorCode | |
) | |
if ($ErrorCode -le 0) { | |
return $ErrorCode | |
} else { | |
return (($ErrorCode -band 0x0000FFFF) -bor (7 -shl 16)) -bor 0x80000000 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment