mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
marshal return types, add CharSet.Unicode to functions that lack it, marshal BOOL parameters
This commit is contained in:
parent
e9ab99c5ac
commit
d780d337e4
7 changed files with 18 additions and 10 deletions
|
@ -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