mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Merged in dpbremner/greenshot (pull request #15)
marshal return types, add CharSet.Unicode to functions that lack it, marshal BOOL parameters
This commit is contained in:
commit
02a06a12b0
7 changed files with 18 additions and 10 deletions
|
@ -645,6 +645,7 @@ namespace Greenshot.Helpers
|
|||
#region GET
|
||||
#region PRODUCT INFO
|
||||
[DllImport("Kernel32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool GetProductInfo(
|
||||
int osMajorVersion,
|
||||
int osMinorVersion,
|
||||
|
@ -654,7 +655,8 @@ namespace Greenshot.Helpers
|
|||
#endregion PRODUCT INFO
|
||||
|
||||
#region VERSION
|
||||
[DllImport("kernel32.dll")]
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
|
||||
#endregion VERSION
|
||||
#endregion GET
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>Encapsulates dialog functionality from the Credential Management API.</summary>
|
||||
public sealed class CredentialsDialog {
|
||||
[DllImport("gdi32.dll", SetLastError=true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
/// <summary>The only valid bitmap height (in pixels) of a user-defined banner.</summary>
|
||||
|
@ -602,6 +603,6 @@ namespace GreenshotPlugin.Core {
|
|||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/creduiconfirmcredentials.asp
|
||||
/// </summary>
|
||||
[DllImport("credui.dll", CharSet=CharSet.Unicode)]
|
||||
public static extern ReturnCodes CredUIConfirmCredentials(string targetName, bool confirm);
|
||||
public static extern ReturnCodes CredUIConfirmCredentials(string targetName, [MarshalAs(UnmanagedType.Bool)] bool confirm);
|
||||
}
|
||||
}
|
|
@ -423,6 +423,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="hObject"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("gdi32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
private WindowCapture() {
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
/// </summary>
|
||||
public abstract class SafeObjectHandle : SafeHandleZeroOrMinusOneIsInvalid {
|
||||
[DllImport("gdi32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
protected SafeObjectHandle(bool ownsHandle) : base(ownsHandle) {
|
||||
|
@ -149,7 +150,8 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
/// </summary>
|
||||
public class SafeCompatibleDCHandle : SafeDCHandle {
|
||||
[DllImport("gdi32", SetLastError = true)]
|
||||
private static extern bool DeleteDC(IntPtr hDC);
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool DeleteDC(IntPtr hDC);
|
||||
|
||||
[SecurityCritical]
|
||||
private SafeCompatibleDCHandle() : base(true) {
|
||||
|
|
|
@ -58,12 +58,14 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[DllImport("kernel32", SetLastError = true)]
|
||||
public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, int dwProcessId);
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool QueryFullProcessImageName(IntPtr hProcess, uint dwFlags, StringBuilder lpExeName, ref uint lpdwSize);
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern uint QueryDosDevice(string lpDeviceName, StringBuilder lpTargetPath, uint uuchMax);
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -49,12 +49,12 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
public SHITEMID mkid;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
|
||||
private struct BROWSEINFO {
|
||||
public IntPtr hwndOwner;
|
||||
public IntPtr pidlRoot;
|
||||
public IntPtr pszDisplayName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string lpszTitle;
|
||||
public uint ulFlags;
|
||||
public IntPtr lpfn;
|
||||
|
|
|
@ -104,14 +104,14 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
public extern static bool IsZoomed(IntPtr hwnd);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public extern static int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern uint GetClassLong(IntPtr hWnd, int nIndex);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "GetClassLongPtr")]
|
||||
public static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
|
||||
[DllImport("user32", SetLastError=true)]
|
||||
[DllImport("user32", CharSet=CharSet.Unicode, SetLastError=true)]
|
||||
public extern static IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public extern static IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
|
||||
|
@ -119,7 +119,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
public extern static int GetWindowLong(IntPtr hwnd, int index);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "GetWindowLongPtr")]
|
||||
public extern static IntPtr GetWindowLongPtr(IntPtr hwnd, int nIndex);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern int SetWindowLong(IntPtr hWnd, int index, int styleFlags);
|
||||
[DllImport("user32", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
|
||||
public static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int index, IntPtr styleFlags);
|
||||
|
@ -139,9 +139,9 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool ShowScrollBar(IntPtr hwnd, ScrollBarDirection scrollBar, bool show);
|
||||
public static extern bool ShowScrollBar(IntPtr hwnd, ScrollBarDirection scrollBar, [MarshalAs(UnmanagedType.Bool)] bool show);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, bool bRedraw);
|
||||
public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern RegionResult GetWindowRgn(IntPtr hWnd, SafeHandle hRgn);
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue