-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #299. This method should be reliable for just about any situation. However it's only been thoroughly tested by myself. It may break completely for others. Please provide feedback.
- Loading branch information
David Rudie
committed
Jul 21, 2018
1 parent
a6564ec
commit a6da1d4
Showing
8 changed files
with
1,090 additions
and
360 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#region File Information | ||
/* | ||
* Copyright (C) 2006 Michael Schierl | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. | ||
*/ | ||
#endregion | ||
|
||
namespace ManagedWindowsFunctions | ||
{ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Runtime.InteropServices; | ||
|
||
/// <summary> | ||
/// Helper class that contains static methods useful for API programming. This | ||
/// class is not exposed to the user. | ||
/// </summary> | ||
internal static class ApiHelper | ||
{ | ||
/// <summary> | ||
/// Throw a <see cref="Win32Exception"/> if the supplied (return) value is zero. | ||
/// This exception uses the last Win32 error code as error message. | ||
/// </summary> | ||
/// <param name="returnValue">The return value to test.</param> | ||
/// <returns>This will return the return value unless it is 0.</returns> | ||
/* | ||
internal static int FailIfZero(int returnValue) | ||
{ | ||
if (returnValue == 0) | ||
{ | ||
throw new Win32Exception(Marshal.GetLastWin32Error()); | ||
} | ||
return returnValue; | ||
} | ||
*/ | ||
|
||
/// <summary> | ||
/// Throw a <see cref="Win32Exception"/> if the supplied (return) value is zero. | ||
/// This exception uses the last Win32 error code as error message. | ||
/// </summary> | ||
/// <param name="returnValue">The return value to test.</param> | ||
/// <returns>This will return the return value unless it is 0.</returns> | ||
internal static IntPtr FailIfZero(IntPtr returnValue) | ||
{ | ||
if (returnValue == IntPtr.Zero) | ||
{ | ||
throw new Win32Exception(Marshal.GetLastWin32Error()); | ||
} | ||
|
||
return returnValue; | ||
} | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.