Changeset 1559 for branches/eraser6/CodeReview/Eraser.Util/KernelApi.cs
- Timestamp:
- 1/18/2010 5:59:07 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/CodeReview/Eraser.Util/KernelApi.cs
r1543 r1559 59 59 /// are created as detached processes (by calling the CreateProcess function 60 60 /// with the DETACHED_PROCESS flag).</remarks> 61 [Obsolete] 61 62 public static bool AllocConsole() 62 63 { … … 81 82 /// After a process calls FreeConsole, it can call the AllocConsole function to 82 83 /// create a new console or AttachConsole to attach to another console.</remarks> 84 [Obsolete] 83 85 public static bool FreeConsole() 84 86 { … … 103 105 104 106 return result; 105 }106 107 /// <summary>108 /// Converts a Win32 Error code to a HRESULT.109 /// </summary>110 /// <param name="errorCode">The error code to convert.</param>111 /// <returns>A HRESULT value representing the error code.</returns>112 internal static int GetHRForWin32Error(int errorCode)113 {114 const uint FACILITY_WIN32 = 7;115 return errorCode <= 0 ? errorCode :116 (int)((((uint)errorCode) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000);117 }118 119 /// <summary>120 /// Gets a Exception for the given Win32 error code.121 /// </summary>122 /// <param name="errorCode">The error code.</param>123 /// <returns>An exception object representing the error code.</returns>124 internal static Exception GetExceptionForWin32Error(int errorCode)125 {126 int HR = GetHRForWin32Error(errorCode);127 return Marshal.GetExceptionForHR(HR);128 107 } 129 108 … … 177 156 throw KernelApi.GetExceptionForWin32Error(Marshal.GetLastWin32Error()); 178 157 } 158 } 159 160 /// <summary> 161 /// Converts a Win32 Error code to a HRESULT. 162 /// </summary> 163 /// <param name="errorCode">The error code to convert.</param> 164 /// <returns>A HRESULT value representing the error code.</returns> 165 internal static int GetHRForWin32Error(int errorCode) 166 { 167 const uint FACILITY_WIN32 = 7; 168 return errorCode <= 0 ? errorCode : 169 (int)((((uint)errorCode) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000); 170 } 171 172 /// <summary> 173 /// Gets a Exception for the given Win32 error code. 174 /// </summary> 175 /// <param name="errorCode">The error code.</param> 176 /// <returns>An exception object representing the error code.</returns> 177 internal static Exception GetExceptionForWin32Error(int errorCode) 178 { 179 int HR = GetHRForWin32Error(errorCode); 180 return Marshal.GetExceptionForHR(HR); 179 181 } 180 182
Note: See TracChangeset
for help on using the changeset viewer.
