Moving back to trunk!

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-01-24 19:24:36 +00:00
commit 8d458998a1
332 changed files with 17647 additions and 9466 deletions

View file

@ -0,0 +1,123 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers {
// See: http://msdn.microsoft.com/en-us/library/aa969502(v=vs.85).aspx
[StructLayout(LayoutKind.Sequential)]
public struct DWM_THUMBNAIL_PROPERTIES {
// A bitwise combination of DWM thumbnail constant values that indicates which members of this structure are set.
public int dwFlags;
// The area in the destination window where the thumbnail will be rendered.
public RECT rcDestination;
// The region of the source window to use as the thumbnail. By default, the entire window is used as the thumbnail.
public RECT rcSource;
// The opacity with which to render the thumbnail. 0 is fully transparent while 255 is fully opaque. The default value is 255.
public byte opacity;
// TRUE to make the thumbnail visible; otherwise, FALSE. The default is FALSE.
public bool fVisible;
// TRUE to use only the thumbnail source's client area; otherwise, FALSE. The default is FALSE.
public bool fSourceClientAreaOnly;
public RECT Destination {
set {
dwFlags |= DWM_TNP_RECTDESTINATION;
rcDestination = value;
}
}
public RECT Source {
set {
dwFlags |= DWM_TNP_RECTSOURCE;
rcSource = value;
}
}
public byte Opacity {
set {
dwFlags |= DWM_TNP_OPACITY;
opacity = value;
}
}
public bool Visible {
set {
dwFlags |= DWM_TNP_VISIBLE;
fVisible = value;
}
}
public bool SourceClientAreaOnly {
set {
dwFlags |= DWM_TNP_SOURCECLIENTAREAONLY;
fSourceClientAreaOnly = value;
}
}
// A value for the rcDestination member has been specified.
public const int DWM_TNP_RECTDESTINATION = 0x00000001;
// A value for the rcSource member has been specified.
public const int DWM_TNP_RECTSOURCE = 0x00000002;
// A value for the opacity member has been specified.
public const int DWM_TNP_OPACITY = 0x00000004;
// A value for the fVisible member has been specified.
public const int DWM_TNP_VISIBLE = 0x00000008;
// A value for the fSourceClientAreaOnly member has been specified.
public const int DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
}
[StructLayout(LayoutKind.Sequential)]
public struct DWM_BLURBEHIND {
public DWM_BB dwFlags;
public bool fEnable;
public IntPtr hRgnBlur;
public bool fTransitionOnMaximized;
}
/// <summary>
/// Description of DWM.
/// </summary>
public class DWM {
// DWM
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmRegisterThumbnail(IntPtr dest, IntPtr src, out IntPtr thumb);
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmUnregisterThumbnail(IntPtr thumb);
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmQueryThumbnailSourceSize(IntPtr thumb, out SIZE size);
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmUpdateThumbnailProperties(IntPtr hThumb, ref DWM_THUMBNAIL_PROPERTIES props);
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmIsCompositionEnabled(out bool enabled);
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out RECT lpRect, int size);
[DllImport("dwmapi", SetLastError = true)]
public static extern int DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
/// <summary>
/// Helper method for an easy DWM check
/// </summary>
/// <returns>bool true if DWM is available AND active</returns>
public static bool isDWMEnabled() {
if (Environment.OSVersion.Version.Major >= 6) {
bool dwmEnabled;
DWM.DwmIsCompositionEnabled(out dwmEnabled);
return dwmEnabled;
}
return false;
}
}
}

View file

@ -0,0 +1,929 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
namespace GreenshotPlugin.UnmanagedHelpers {
/// <summary>
/// Window Style Flags
/// </summary>
[Flags]
public enum WindowStyleFlags : uint {
//WS_OVERLAPPED = 0x00000000,
WS_POPUP = 0x80000000,
WS_CHILD = 0x40000000,
WS_MINIMIZE = 0x20000000,
WS_VISIBLE = 0x10000000,
WS_DISABLED = 0x08000000,
WS_CLIPSIBLINGS = 0x04000000,
WS_CLIPCHILDREN = 0x02000000,
WS_MAXIMIZE = 0x01000000,
WS_BORDER = 0x00800000,
WS_DLGFRAME = 0x00400000,
WS_VSCROLL = 0x00200000,
WS_HSCROLL = 0x00100000,
WS_SYSMENU = 0x00080000,
WS_THICKFRAME = 0x00040000,
WS_GROUP = 0x00020000,
WS_TABSTOP = 0x00010000,
WS_UNK8000 = 0x00008000,
WS_UNK4000 = 0x00004000,
WS_UNK2000 = 0x00002000,
WS_UNK1000 = 0x00001000,
WS_UNK800 = 0x00000800,
WS_UNK400 = 0x00000400,
WS_UNK200 = 0x00000200,
WS_UNK100 = 0x00000100,
WS_UNK80 = 0x00000080,
WS_UNK40 = 0x00000040,
WS_UNK20 = 0x00000020,
WS_UNK10 = 0x00000010,
WS_UNK8 = 0x00000008,
WS_UNK4 = 0x00000004,
WS_UNK2 = 0x00000002,
WS_UNK1 = 0x00000001,
//WS_MINIMIZEBOX = 0x00020000,
//WS_MAXIMIZEBOX = 0x00010000,
//WS_CAPTION = WS_BORDER | WS_DLGFRAME,
//WS_TILED = WS_OVERLAPPED,
//WS_ICONIC = WS_MINIMIZE,
//WS_SIZEBOX = WS_THICKFRAME,
//WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW,
//WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
//WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU
//WS_CHILDWINDOW = WS_CHILD
}
[Flags]
public enum ExtendedWindowStyleFlags : uint {
WS_EX_DLGMODALFRAME = 0x00000001,
WS_EX_NOPARENTNOTIFY = 0x00000004,
WS_EX_TOPMOST = 0x00000008,
WS_EX_ACCEPTFILES = 0x00000010,
WS_EX_TRANSPARENT = 0x00000020,
//#if(WINVER >= 0x0400)
WS_EX_MDICHILD = 0x00000040,
WS_EX_TOOLWINDOW = 0x00000080,
WS_EX_WINDOWEDGE = 0x00000100,
WS_EX_CLIENTEDGE = 0x00000200,
WS_EX_CONTEXTHELP = 0x00000400,
WS_EX_RIGHT = 0x00001000,
WS_EX_LEFT = 0x00000000,
WS_EX_RTLREADING = 0x00002000,
WS_EX_LTRREADING = 0x00000000,
WS_EX_LEFTSCROLLBAR = 0x00004000,
WS_EX_RIGHTSCROLLBAR = 0x00000000,
WS_EX_CONTROLPARENT = 0x00010000,
WS_EX_STATICEDGE = 0x00020000,
WS_EX_APPWINDOW = 0x00040000,
//WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
//WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),
WS_EX_LAYERED = 0x00080000,
WS_EX_NOINHERITLAYOUT = 0x00100000, // Disable inheritence of mirroring by children
WS_EX_LAYOUTRTL = 0x00400000, // Right to left mirroring
WS_EX_COMPOSITED = 0x02000000,
WS_EX_NOACTIVATE = 0x08000000
}
[Flags]
public enum WindowPlacementFlags : uint {
// The coordinates of the minimized window may be specified.
// This flag must be specified if the coordinates are set in the ptMinPosition member.
WPF_SETMINPOSITION = 0x0001,
// If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
WPF_ASYNCWINDOWPLACEMENT = 0x0004,
// The restored window will be maximized, regardless of whether it was maximized before it was minimized. This setting is only valid the next time the window is restored. It does not change the default restoration behavior.
// This flag is only valid when the SW_SHOWMINIMIZED value is specified for the showCmd member.
WPF_RESTORETOMAXIMIZED = 0x0002
}
public enum ShowWindowCommand : uint {
/// <summary>
/// Hides the window and activates another window.
/// </summary>
Hide = 0,
/// <summary>
/// Activates and displays a window. If the window is minimized or
/// maximized, the system restores it to its original size and position.
/// An application should specify this flag when displaying the window
/// for the first time.
/// </summary>
Normal = 1,
/// <summary>
/// Activates the window and displays it as a minimized window.
/// </summary>
ShowMinimized = 2,
/// <summary>
/// Maximizes the specified window.
/// </summary>
Maximize = 3, // is this the right value?
/// <summary>
/// Activates the window and displays it as a maximized window.
/// </summary>
ShowMaximized = 3,
/// <summary>
/// Displays a window in its most recent size and position. This value
/// is similar to <see cref="Win32.ShowWindowCommand.Normal"/>, except
/// the window is not actived.
/// </summary>
ShowNoActivate = 4,
/// <summary>
/// Activates the window and displays it in its current size and position.
/// </summary>
Show = 5,
/// <summary>
/// Minimizes the specified window and activates the next top-level
/// window in the Z order.
/// </summary>
Minimize = 6,
/// <summary>
/// Displays the window as a minimized window. This value is similar to
/// <see cref="Win32.ShowWindowCommand.ShowMinimized"/>, except the
/// window is not activated.
/// </summary>
ShowMinNoActive = 7,
/// <summary>
/// Displays the window in its current size and position. This value is
/// similar to <see cref="Win32.ShowWindowCommand.Show"/>, except the
/// window is not activated.
/// </summary>
ShowNA = 8,
/// <summary>
/// Activates and displays the window. If the window is minimized or
/// maximized, the system restores it to its original size and position.
/// An application should specify this flag when restoring a minimized window.
/// </summary>
Restore = 9,
/// <summary>
/// Sets the show state based on the SW_* value specified in the
/// STARTUPINFO structure passed to the CreateProcess function by the
/// program that started the application.
/// </summary>
ShowDefault = 10,
/// <summary>
/// <b>Windows 2000/XP:</b> Minimizes a window, even if the thread
/// that owns the window is not responding. This flag should only be
/// used when minimizing windows from a different thread.
/// </summary>
ForceMinimize = 11
}
public enum SYSCOLOR : int {
SCROLLBAR = 0,
BACKGROUND = 1,
DESKTOP = 1,
ACTIVECAPTION = 2,
INACTIVECAPTION = 3,
MENU = 4,
WINDOW = 5,
WINDOWFRAME = 6,
MENUTEXT = 7,
WINDOWTEXT = 8,
CAPTIONTEXT = 9,
ACTIVEBORDER = 10,
INACTIVEBORDER = 11,
APPWORKSPACE = 12,
HIGHLIGHT = 13,
HIGHLIGHTTEXT = 14,
BTNFACE = 15,
THREEDFACE = 15,
BTNSHADOW = 16,
THREEDSHADOW = 16,
GRAYTEXT = 17,
BTNTEXT = 18,
INACTIVECAPTIONTEXT = 19,
BTNHIGHLIGHT = 20,
TREEDHIGHLIGHT = 20,
THREEDHILIGHT = 20,
BTNHILIGHT = 20,
THREEDDKSHADOW = 21,
THREEDLIGHT = 22,
INFOTEXT = 23,
INFOBK = 24
}
/// <summary>
/// Flags used with the Windows API (User32.dll):GetSystemMetrics(SystemMetric smIndex)
///
/// This Enum and declaration signature was written by Gabriel T. Sharp
/// ai_productions@verizon.net or osirisgothra@hotmail.com
/// Obtained on pinvoke.net, please contribute your code to support the wiki!
/// </summary>
public enum SystemMetric : int {
/// <summary>
/// Width of the screen of the primary display monitor, in pixels. This is the same values obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES).
/// </summary>
SM_CXSCREEN=0,
/// <summary>
/// Height of the screen of the primary display monitor, in pixels. This is the same values obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES).
/// </summary>
SM_CYSCREEN=1,
/// <summary>
/// Width of a horizontal scroll bar, in pixels.
/// </summary>
SM_CYVSCROLL=2,
/// <summary>
/// Height of a horizontal scroll bar, in pixels.
/// </summary>
SM_CXVSCROLL=3,
/// <summary>
/// Height of a caption area, in pixels.
/// </summary>
SM_CYCAPTION=4,
/// <summary>
/// Width of a window border, in pixels. This is equivalent to the SM_CXEDGE value for windows with the 3-D look.
/// </summary>
SM_CXBORDER=5,
/// <summary>
/// Height of a window border, in pixels. This is equivalent to the SM_CYEDGE value for windows with the 3-D look.
/// </summary>
SM_CYBORDER=6,
/// <summary>
/// Thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels. SM_CXFIXEDFRAME is the height of the horizontal border and SM_CYFIXEDFRAME is the width of the vertical border.
/// </summary>
SM_CXDLGFRAME=7,
/// <summary>
/// Thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels. SM_CXFIXEDFRAME is the height of the horizontal border and SM_CYFIXEDFRAME is the width of the vertical border.
/// </summary>
SM_CYDLGFRAME=8,
/// <summary>
/// Height of the thumb box in a vertical scroll bar, in pixels
/// </summary>
SM_CYVTHUMB=9,
/// <summary>
/// Width of the thumb box in a horizontal scroll bar, in pixels.
/// </summary>
SM_CXHTHUMB=10,
/// <summary>
/// Default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions specified by SM_CXICON and SM_CYICON
/// </summary>
SM_CXICON=11,
/// <summary>
/// Default height of an icon, in pixels. The LoadIcon function can load only icons with the dimensions SM_CXICON and SM_CYICON.
/// </summary>
SM_CYICON=12,
/// <summary>
/// Width of a cursor, in pixels. The system cannot create cursors of other sizes.
/// </summary>
SM_CXCURSOR=13,
/// <summary>
/// Height of a cursor, in pixels. The system cannot create cursors of other sizes.
/// </summary>
SM_CYCURSOR=14,
/// <summary>
/// Height of a single-line menu bar, in pixels.
/// </summary>
SM_CYMENU=15,
/// <summary>
/// Width of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value.
/// </summary>
SM_CXFULLSCREEN=16,
/// <summary>
/// Height of the client area for a full-screen window on the primary display monitor, in pixels. To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, call the SystemParametersInfo function with the SPI_GETWORKAREA value.
/// </summary>
SM_CYFULLSCREEN=17,
/// <summary>
/// For double byte character set versions of the system, this is the height of the Kanji window at the bottom of the screen, in pixels
/// </summary>
SM_CYKANJIWINDOW=18,
/// <summary>
/// Nonzero if a mouse with a wheel is installed; zero otherwise
/// </summary>
SM_MOUSEWHEELPRESENT=75,
/// <summary>
/// Height of the arrow bitmap on a vertical scroll bar, in pixels.
/// </summary>
SM_CYHSCROLL=20,
/// <summary>
/// Width of the arrow bitmap on a horizontal scroll bar, in pixels.
/// </summary>
SM_CXHSCROLL=21,
/// <summary>
/// Nonzero if the debug version of User.exe is installed; zero otherwise.
/// </summary>
SM_DEBUG=22,
/// <summary>
/// Nonzero if the left and right mouse buttons are reversed; zero otherwise.
/// </summary>
SM_SWAPBUTTON=23,
/// <summary>
/// Reserved for future use
/// </summary>
SM_RESERVED1=24,
/// <summary>
/// Reserved for future use
/// </summary>
SM_RESERVED2=25,
/// <summary>
/// Reserved for future use
/// </summary>
SM_RESERVED3=26,
/// <summary>
/// Reserved for future use
/// </summary>
SM_RESERVED4=27,
/// <summary>
/// Minimum width of a window, in pixels.
/// </summary>
SM_CXMIN=28,
/// <summary>
/// Minimum height of a window, in pixels.
/// </summary>
SM_CYMIN=29,
/// <summary>
/// Width of a button in a window's caption or title bar, in pixels.
/// </summary>
SM_CXSIZE=30,
/// <summary>
/// Height of a button in a window's caption or title bar, in pixels.
/// </summary>
SM_CYSIZE=31,
/// <summary>
/// Thickness of the sizing border around the perimeter of a window that can be resized, in pixels. SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
/// </summary>
SM_CXFRAME=32,
/// <summary>
/// Thickness of the sizing border around the perimeter of a window that can be resized, in pixels. SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
/// </summary>
SM_CYFRAME=33,
/// <summary>
/// Minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message.
/// </summary>
SM_CXMINTRACK=34,
/// <summary>
/// Minimum tracking height of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message
/// </summary>
SM_CYMINTRACK=35,
/// <summary>
/// Width of the rectangle around the location of a first click in a double-click sequence, in pixels. The second click must occur within the rectangle defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system to consider the two clicks a double-click
/// </summary>
SM_CXDOUBLECLK=36,
/// <summary>
/// Height of the rectangle around the location of a first click in a double-click sequence, in pixels. The second click must occur within the rectangle defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system to consider the two clicks a double-click. (The two clicks must also occur within a specified time.)
/// </summary>
SM_CYDOUBLECLK=37,
/// <summary>
/// Width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CXICON
/// </summary>
SM_CXICONSPACING=38,
/// <summary>
/// Height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CYICON.
/// </summary>
SM_CYICONSPACING=39,
/// <summary>
/// Nonzero if drop-down menus are right-aligned with the corresponding menu-bar item; zero if the menus are left-aligned.
/// </summary>
SM_MENUDROPALIGNMENT=40,
/// <summary>
/// Nonzero if the Microsoft Windows for Pen computing extensions are installed; zero otherwise.
/// </summary>
SM_PENWINDOWS=41,
/// <summary>
/// Nonzero if User32.dll supports DBCS; zero otherwise. (WinMe/95/98): Unicode
/// </summary>
SM_DBCSENABLED=42,
/// <summary>
/// Number of buttons on mouse, or zero if no mouse is installed.
/// </summary>
SM_CMOUSEBUTTONS=43,
/// <summary>
/// Identical Values Changed After Windows NT 4.0
/// </summary>
SM_CXFIXEDFRAME=SM_CXDLGFRAME,
/// <summary>
/// Identical Values Changed After Windows NT 4.0
/// </summary>
SM_CYFIXEDFRAME=SM_CYDLGFRAME,
/// <summary>
/// Identical Values Changed After Windows NT 4.0
/// </summary>
SM_CXSIZEFRAME=SM_CXFRAME,
/// <summary>
/// Identical Values Changed After Windows NT 4.0
/// </summary>
SM_CYSIZEFRAME=SM_CYFRAME,
/// <summary>
/// Nonzero if security is present; zero otherwise.
/// </summary>
SM_SECURE=44,
/// <summary>
/// Width of a 3-D border, in pixels. This is the 3-D counterpart of SM_CXBORDER
/// </summary>
SM_CXEDGE=45,
/// <summary>
/// Height of a 3-D border, in pixels. This is the 3-D counterpart of SM_CYBORDER
/// </summary>
SM_CYEDGE=46,
/// <summary>
/// Width of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged. This value is always greater than or equal to SM_CXMINIMIZED.
/// </summary>
SM_CXMINSPACING=47,
/// <summary>
/// Height of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged. This value is always greater than or equal to SM_CYMINIMIZED.
/// </summary>
SM_CYMINSPACING=48,
/// <summary>
/// Recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view
/// </summary>
SM_CXSMICON=49,
/// <summary>
/// Recommended height of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
/// </summary>
SM_CYSMICON=50,
/// <summary>
/// Height of a small caption, in pixels
/// </summary>
SM_CYSMCAPTION=51,
/// <summary>
/// Width of small caption buttons, in pixels.
/// </summary>
SM_CXSMSIZE=52,
/// <summary>
/// Height of small caption buttons, in pixels.
/// </summary>
SM_CYSMSIZE=53,
/// <summary>
/// Width of menu bar buttons, such as the child window close button used in the multiple document interface, in pixels.
/// </summary>
SM_CXMENUSIZE=54,
/// <summary>
/// Height of menu bar buttons, such as the child window close button used in the multiple document interface, in pixels.
/// </summary>
SM_CYMENUSIZE=55,
/// <summary>
/// Flags specifying how the system arranged minimized windows
/// </summary>
SM_ARRANGE=56,
/// <summary>
/// Width of a minimized window, in pixels.
/// </summary>
SM_CXMINIMIZED=57,
/// <summary>
/// Height of a minimized window, in pixels.
/// </summary>
SM_CYMINIMIZED=58,
/// <summary>
/// Default maximum width of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message.
/// </summary>
SM_CXMAXTRACK=59,
/// <summary>
/// Default maximum height of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing the WM_GETMINMAXINFO message.
/// </summary>
SM_CYMAXTRACK=60,
/// <summary>
/// Default width, in pixels, of a maximized top-level window on the primary display monitor.
/// </summary>
SM_CXMAXIMIZED=61,
/// <summary>
/// Default height, in pixels, of a maximized top-level window on the primary display monitor.
/// </summary>
SM_CYMAXIMIZED=62,
/// <summary>
/// Least significant bit is set if a network is present; otherwise, it is cleared. The other bits are reserved for future use
/// </summary>
SM_NETWORK=63,
/// <summary>
/// Value that specifies how the system was started: 0-normal, 1-failsafe, 2-failsafe /w net
/// </summary>
SM_CLEANBOOT=67,
/// <summary>
/// Width of a rectangle centered on a drag point to allow for limited movement of the mouse pointer before a drag operation begins, in pixels.
/// </summary>
SM_CXDRAG=68,
/// <summary>
/// Height of a rectangle centered on a drag point to allow for limited movement of the mouse pointer before a drag operation begins. This value is in pixels. It allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
/// </summary>
SM_CYDRAG=69,
/// <summary>
/// Nonzero if the user requires an application to present information visually in situations where it would otherwise present the information only in audible form; zero otherwise.
/// </summary>
SM_SHOWSOUNDS=70,
/// <summary>
/// Width of the default menu check-mark bitmap, in pixels.
/// </summary>
SM_CXMENUCHECK=71,
/// <summary>
/// Height of the default menu check-mark bitmap, in pixels.
/// </summary>
SM_CYMENUCHECK=72,
/// <summary>
/// Nonzero if the computer has a low-end (slow) processor; zero otherwise
/// </summary>
SM_SLOWMACHINE=73,
/// <summary>
/// Nonzero if the system is enabled for Hebrew and Arabic languages, zero if not.
/// </summary>
SM_MIDEASTENABLED=74,
/// <summary>
/// Nonzero if a mouse is installed; zero otherwise. This value is rarely zero, because of support for virtual mice and because some systems detect the presence of the port instead of the presence of a mouse.
/// </summary>
SM_MOUSEPRESENT=19,
/// <summary>
/// Windows 2000 (v5.0+) Coordinate of the top of the virtual screen
/// </summary>
SM_XVIRTUALSCREEN=76,
/// <summary>
/// Windows 2000 (v5.0+) Coordinate of the left of the virtual screen
/// </summary>
SM_YVIRTUALSCREEN=77,
/// <summary>
/// Windows 2000 (v5.0+) Width of the virtual screen
/// </summary>
SM_CXVIRTUALSCREEN=78,
/// <summary>
/// Windows 2000 (v5.0+) Height of the virtual screen
/// </summary>
SM_CYVIRTUALSCREEN=79,
/// <summary>
/// Number of display monitors on the desktop
/// </summary>
SM_CMONITORS=80,
/// <summary>
/// Windows XP (v5.1+) Nonzero if all the display monitors have the same color format, zero otherwise. Note that two displays can have the same bit depth, but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits, or those bits can be located in different places in a pixel's color value.
/// </summary>
SM_SAMEDISPLAYFORMAT=81,
/// <summary>
/// Windows XP (v5.1+) Nonzero if Input Method Manager/Input Method Editor features are enabled; zero otherwise
/// </summary>
SM_IMMENABLED=82,
/// <summary>
/// Windows XP (v5.1+) Width of the left and right edges of the focus rectangle drawn by DrawFocusRect. This value is in pixels.
/// </summary>
SM_CXFOCUSBORDER=83,
/// <summary>
/// Windows XP (v5.1+) Height of the top and bottom edges of the focus rectangle drawn by DrawFocusRect. This value is in pixels.
/// </summary>
SM_CYFOCUSBORDER=84,
/// <summary>
/// Nonzero if the current operating system is the Windows XP Tablet PC edition, zero if not.
/// </summary>
SM_TABLETPC=86,
/// <summary>
/// Nonzero if the current operating system is the Windows XP, Media Center Edition, zero if not.
/// </summary>
SM_MEDIACENTER=87,
/// <summary>
/// Metrics Other
/// </summary>
SM_CMETRICS_OTHER=76,
/// <summary>
/// Metrics Windows 2000
/// </summary>
SM_CMETRICS_2000=83,
/// <summary>
/// Metrics Windows NT
/// </summary>
SM_CMETRICS_NT=88,
/// <summary>
/// Windows XP (v5.1+) This system metric is used in a Terminal Services environment. If the calling process is associated with a Terminal Services client session, the return value is nonzero. If the calling process is associated with the Terminal Server console session, the return value is zero. The console session is not necessarily the physical console - see WTSGetActiveConsoleSessionId for more information.
/// </summary>
SM_REMOTESESSION=0x1000,
/// <summary>
/// Windows XP (v5.1+) Nonzero if the current session is shutting down; zero otherwise
/// </summary>
SM_SHUTTINGDOWN=0x2000,
/// <summary>
/// Windows XP (v5.1+) This system metric is used in a Terminal Services environment. Its value is nonzero if the current session is remotely controlled; zero otherwise
/// </summary>
SM_REMOTECONTROL=0x2001
}
public enum RegionResult {
REGION_ERROR = 0,
REGION_NULLREGION = 1,
REGION_SIMPLEREGION = 2,
REGION_COMPLEXREGION = 3
}
// See http://msdn.microsoft.com/en-us/library/aa969530(v=vs.85).aspx
public enum DWMWINDOWATTRIBUTE {
DWMWA_NCRENDERING_ENABLED = 1,
DWMWA_NCRENDERING_POLICY,
DWMWA_TRANSITIONS_FORCEDISABLED,
DWMWA_ALLOW_NCPAINT,
DWMWA_CAPTION_BUTTON_BOUNDS,
DWMWA_NONCLIENT_RTL_LAYOUT,
DWMWA_FORCE_ICONIC_REPRESENTATION,
DWMWA_FLIP3D_POLICY,
DWMWA_EXTENDED_FRAME_BOUNDS, // This is the one we need for retrieving the Window size since Windows Vista
DWMWA_HAS_ICONIC_BITMAP,
DWMWA_DISALLOW_PEEK,
DWMWA_LAST
}
public enum GetWindowCommand : uint {
GW_HWNDFIRST = 0,
GW_HWNDLAST = 1,
GW_HWNDNEXT = 2,
GW_HWNDPREV = 3,
GW_OWNER = 4,
GW_CHILD = 5,
GW_ENABLEDPOPUP = 6
}
[Flags]
public enum DWM_BB {
Enable = 1,
BlurRegion = 2,
TransitionMaximized = 4
}
public enum WindowsMessages : int {
WM_NULL = 0x0000,
WM_CREATE = 0x0001,
WM_DESTROY = 0x0002,
WM_MOVE = 0x0003,
WM_SIZE = 0x0005,
WM_ACTIVATE = 0x0006,
WM_SETFOCUS = 0x0007,
WM_KILLFOCUS = 0x0008,
WM_ENABLE = 0x000A,
WM_SETREDRAW = 0x000B,
WM_SETTEXT = 0x000C,
WM_GETTEXT = 0x000D,
WM_GETTEXTLENGTH = 0x000E,
WM_PAINT = 0x000F,
WM_CLOSE = 0x0010,
WM_QUERYENDSESSION = 0x0011,
WM_QUIT = 0x0012,
WM_QUERYOPEN = 0x0013,
WM_ERASEBKGND = 0x0014,
WM_SYSCOLORCHANGE = 0x0015,
WM_ENDSESSION = 0x0016,
WM_SHOWWINDOW = 0x0018,
WM_WININICHANGE = 0x001A,
WM_SETTINGCHANGE = 0x001A,
WM_DEVMODECHANGE = 0x001B,
WM_ACTIVATEAPP = 0x001C,
WM_FONTCHANGE = 0x001D,
WM_TIMECHANGE = 0x001E,
WM_CANCELMODE = 0x001F,
WM_SETCURSOR = 0x0020,
WM_MOUSEACTIVATE = 0x0021,
WM_CHILDACTIVATE = 0x0022,
WM_QUEUESYNC = 0x0023,
WM_GETMINMAXINFO = 0x0024,
WM_PAINTICON = 0x0026,
WM_ICONERASEBKGND = 0x0027,
WM_NEXTDLGCTL = 0x0028,
WM_SPOOLERSTATUS = 0x002A,
WM_DRAWITEM = 0x002B,
WM_MEASUREITEM = 0x002C,
WM_DELETEITEM = 0x002D,
WM_VKEYTOITEM = 0x002E,
WM_CHARTOITEM = 0x002F,
WM_SETFONT = 0x0030,
WM_GETFONT = 0x0031,
WM_SETHOTKEY = 0x0032,
WM_GETHOTKEY = 0x0033,
WM_QUERYDRAGICON = 0x0037,
WM_COMPAREITEM = 0x0039,
WM_GETOBJECT = 0x003D,
WM_COMPACTING = 0x0041,
WM_COMMNOTIFY = 0x0044,
WM_WINDOWPOSCHANGING = 0x0046,
WM_WINDOWPOSCHANGED = 0x0047,
WM_POWER = 0x0048,
WM_COPYDATA = 0x004A,
WM_CANCELJOURNAL = 0x004B,
WM_NOTIFY = 0x004E,
WM_INPUTLANGCHANGEREQUEST = 0x0050,
WM_INPUTLANGCHANGE = 0x0051,
WM_TCARD = 0x0052,
WM_HELP = 0x0053,
WM_USERCHANGED = 0x0054,
WM_NOTIFYFORMAT = 0x0055,
WM_CONTEXTMENU = 0x007B,
WM_STYLECHANGING = 0x007C,
WM_STYLECHANGED = 0x007D,
WM_DISPLAYCHANGE = 0x007E,
WM_GETICON = 0x007F,
WM_SETICON = 0x0080,
WM_NCCREATE = 0x0081,
WM_NCDESTROY = 0x0082,
WM_NCCALCSIZE = 0x0083,
WM_NCHITTEST = 0x0084,
WM_NCPAINT = 0x0085,
WM_NCACTIVATE = 0x0086,
WM_GETDLGCODE = 0x0087,
WM_SYNCPAINT = 0x0088,
WM_NCMOUSEMOVE = 0x00A0,
WM_NCLBUTTONDOWN = 0x00A1,
WM_NCLBUTTONUP = 0x00A2,
WM_NCLBUTTONDBLCLK = 0x00A3,
WM_NCRBUTTONDOWN = 0x00A4,
WM_NCRBUTTONUP = 0x00A5,
WM_NCRBUTTONDBLCLK = 0x00A6,
WM_NCMBUTTONDOWN = 0x00A7,
WM_NCMBUTTONUP = 0x00A8,
WM_NCMBUTTONDBLCLK = 0x00A9,
WM_KEYFIRST = 0x0100,
WM_KEYDOWN = 0x0100,
WM_KEYUP = 0x0101,
WM_CHAR = 0x0102,
WM_DEADCHAR = 0x0103,
WM_SYSKEYDOWN = 0x0104,
WM_SYSKEYUP = 0x0105,
WM_SYSCHAR = 0x0106,
WM_SYSDEADCHAR = 0x0107,
WM_KEYLAST = 0x0108,
WM_IME_STARTCOMPOSITION = 0x010D,
WM_IME_ENDCOMPOSITION = 0x010E,
WM_IME_COMPOSITION = 0x010F,
WM_IME_KEYLAST = 0x010F,
WM_INITDIALOG = 0x0110,
WM_COMMAND = 0x0111,
WM_SYSCOMMAND = 0x0112,
WM_TIMER = 0x0113,
WM_HSCROLL = 0x0114,
WM_VSCROLL = 0x0115,
WM_INITMENU = 0x0116,
WM_INITMENUPOPUP = 0x0117,
WM_MENUSELECT = 0x011F,
WM_MENUCHAR = 0x0120,
WM_ENTERIDLE = 0x0121,
WM_MENURBUTTONUP = 0x0122,
WM_MENUDRAG = 0x0123,
WM_MENUGETOBJECT = 0x0124,
WM_UNINITMENUPOPUP = 0x0125,
WM_MENUCOMMAND = 0x0126,
WM_CTLCOLORMSGBOX = 0x0132,
WM_CTLCOLOREDIT = 0x0133,
WM_CTLCOLORLISTBOX = 0x0134,
WM_CTLCOLORBTN = 0x0135,
WM_CTLCOLORDLG = 0x0136,
WM_CTLCOLORSCROLLBAR = 0x0137,
WM_CTLCOLORSTATIC = 0x0138,
WM_MOUSEMOVE = 0x0200,
WM_MOUSEFIRST = 0x0200,
WM_LBUTTONDOWN = 0x0201,
WM_LBUTTONUP = 0x0202,
WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_RBUTTONDBLCLK = 0x0206,
WM_MBUTTONDOWN = 0x0207,
WM_MBUTTONUP = 0x0208,
WM_MBUTTONDBLCLK = 0x0209,
WM_MOUSEWHEEL = 0x020A,
WM_MOUSELAST = 0x020A,
WM_PARENTNOTIFY = 0x0210,
WM_ENTERMENULOOP = 0x0211,
WM_EXITMENULOOP = 0x0212,
WM_SIZING = 0x0214,
WM_CAPTURECHANGED = 0x0215,
WM_MOVING = 0x0216,
WM_POWERBROADCAST = 0x0218,
WM_DEVICECHANGE = 0x0219,
WM_MDICREATE = 0x0220,
WM_MDIDESTROY = 0x0221,
WM_MDIACTIVATE = 0x0222,
WM_MDIRESTORE = 0x0223,
WM_MDINEXT = 0x0224,
WM_MDIMAXIMIZE = 0x0225,
WM_MDITILE = 0x0226,
WM_MDICASCADE = 0x0227,
WM_MDIICONARRANGE = 0x0228,
WM_MDIGETACTIVE = 0x0229,
WM_MDISETMENU = 0x0230,
WM_ENTERSIZEMOVE = 0x0231,
WM_EXITSIZEMOVE = 0x0232,
WM_DROPFILES = 0x0233,
WM_MDIREFRESHMENU = 0x0234,
WM_IME_SETCONTEXT = 0x0281,
WM_IME_NOTIFY = 0x0282,
WM_IME_CONTROL = 0x0283,
WM_IME_COMPOSITIONFULL = 0x0284,
WM_IME_SELECT = 0x0285,
WM_IME_CHAR = 0x0286,
WM_IME_REQUEST = 0x0288,
WM_IME_KEYDOWN = 0x0290,
WM_IME_KEYUP = 0x0291,
WM_NCMOUSEHOVER = 0x02A0,
WM_MOUSEHOVER = 0x02A1,
WM_NCMOUSELEAVE = 0x02A2,
WM_MOUSELEAVE = 0x02A3,
WM_CUT = 0x0300,
WM_COPY = 0x0301,
WM_PASTE = 0x0302,
WM_CLEAR = 0x0303,
WM_UNDO = 0x0304,
WM_RENDERFORMAT = 0x0305,
WM_RENDERALLFORMATS = 0x0306,
WM_DESTROYCLIPBOARD = 0x0307,
WM_DRAWCLIPBOARD = 0x0308,
WM_PAINTCLIPBOARD = 0x0309,
WM_VSCROLLCLIPBOARD = 0x030A,
WM_SIZECLIPBOARD = 0x030B,
WM_ASKCBFORMATNAME = 0x030C,
WM_CHANGECBCHAIN = 0x030D,
WM_HSCROLLCLIPBOARD = 0x030E,
WM_QUERYNEWPALETTE = 0x030F,
WM_PALETTEISCHANGING = 0x0310,
WM_PALETTECHANGED = 0x0311,
WM_HOTKEY = 0x0312,
WM_PRINT = 0x0317,
WM_PRINTCLIENT = 0x0318,
WM_HANDHELDFIRST = 0x0358,
WM_HANDHELDLAST = 0x035F,
WM_AFXFIRST = 0x0360,
WM_AFXLAST = 0x037F,
WM_PENWINFIRST = 0x0380,
WM_PENWINLAST = 0x038F,
WM_APP = 0x8000,
WM_USER = 0x0400
}
// Get/Set WindowLong Enum See: http://msdn.microsoft.com/en-us/library/ms633591.aspx
public enum WindowLongIndex : int {
GWL_EXSTYLE = -20, // Sets a new extended window style.
GWL_HINSTANCE = -6, // Sets a new application instance handle.
GWL_ID = -12, // Sets a new identifier of the child window. The window cannot be a top-level window.
GWL_STYLE = -16, // Sets a new window style.
GWL_USERDATA = -21, // Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
GWL_WNDPROC = -4 // Sets a new address for the window procedure. You cannot change this attribute if the window does not belong to the same process as the calling thread.
}
// See: http://msdn.microsoft.com/en-us/library/ms633545.aspx
[Flags]
public enum WindowPos : int {
SWP_ASYNCWINDOWPOS = 0x4000, // If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
SWP_DEFERERASE = 0x2000, // Prevents generation of the WM_SYNCPAINT message.
SWP_DRAWFRAME = 0x0020, // Draws a frame (defined in the window's class description) around the window.
SWP_FRAMECHANGED = 0x0020, //Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
SWP_HIDEWINDOW = 0x0080, // Hides the window.
SWP_NOACTIVATE = 0x0010, // Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
SWP_NOCOPYBITS = 0x0100, // Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
SWP_NOMOVE = 0x0002, //Retains the current position (ignores X and Y parameters).
SWP_NOOWNERZORDER = 0x0200, //Does not change the owner window's position in the Z order.
SWP_NOREDRAW = 0x0008, //Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
SWP_NOREPOSITION = 0x0200, // Same as the SWP_NOOWNERZORDER flag.
SWP_NOSENDCHANGING = 0x0400, //Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
SWP_NOSIZE = 0x0001, // Retains the current size (ignores the cx and cy parameters).
SWP_NOZORDER = 0x0004, // Retains the current Z order (ignores the hWndInsertAfter parameter).
SWP_SHOWWINDOW = 0x0040 //Displays the window.
}
public enum ScrollBarDirection : int {
SB_HORZ = 0,
SB_VERT = 1,
SB_CTL = 2,
SB_BOTH = 3
}
public enum ScrollbarCommand : int {
SB_LINEUP = 0, // Scrolls one line up.
SB_LINEDOWN = 1, // Scrolls one line down.
SB_PAGEUP = 2, // Scrolls one page up.
SB_PAGEDOWN = 3, // Scrolls one page down.
SB_THUMBPOSITION = 4, // The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK = 5, // The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to.
SB_TOP = 6, // Scrolls to the upper left.
SB_BOTTOM = 7, // Scrolls to the lower right.
SB_ENDSCROLL = 8 // Ends scroll.
}
public enum ScrollInfoMask {
SIF_RANGE = 0x1,
SIF_PAGE = 0x2,
SIF_POS = 0x4,
SIF_DISABLENOSCROLL = 0x8,
SIF_TRACKPOS = 0x10,
SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS
}
/// <summary>
/// See: http://www.pinvoke.net/default.aspx/Enums/SendMessageTimeoutFlags.html
/// </summary>
[Flags]
public enum SendMessageTimeoutFlags : uint {
SMTO_NORMAL = 0x0,
SMTO_BLOCK = 0x1,
SMTO_ABORTIFHUNG = 0x2,
SMTO_NOTIMEOUTIFNOTHUNG = 0x8
}
}

View file

@ -0,0 +1,82 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers {
/// <summary>
/// GDI32 Helpers
/// </summary>
public class GDI32 {
[DllImport("gdi32", SetLastError=true)]
public static extern bool BitBlt(IntPtr hObject,int nXDest,int nYDest, int nWidth,int nHeight,IntPtr hObjectSource, int nXSrc,int nYSrc, CopyPixelOperation dwRop);
[DllImport("gdi32", SetLastError=true)]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32", SetLastError=true)]
public static extern bool DeleteDC(IntPtr hDC);
[DllImport("gdi32", SetLastError=true)]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32", SetLastError=true)]
public static extern IntPtr SelectObject(IntPtr hDC,IntPtr hObject);
[DllImport("gdi32", SetLastError=true)]
public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BitmapInfoHeader bmi, uint Usage, out IntPtr bits, IntPtr hSection, uint dwOffset);
[DllImport("gdi32", SetLastError=true)]
public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
[DllImport("gdi32", SetLastError=true)]
public static extern int GetClipBox(IntPtr hdc, out RECT lprc);
}
[StructLayout(LayoutKind.Sequential)]
public struct BitmapInfoHeader {
public uint biSize;
public int biWidth;
public int biHeight;
public short biPlanes;
public short biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public int biClrImportant;
private const int BI_RGB = 0; //Das Bitmap ist nicht komprimiert
private const int BI_RLE8 = 1; //Das Bitmap ist komprimiert (Für 8-Bit Bitmaps)
private const int BI_RLE4 = 2; //Das Bitmap ist komprimiert (Für 4-Bit Bitmaps)
private const int BI_BITFIELDS = 3; //Das Bitmap ist nicht komprimiert. Die Farbtabelle enthält
public const int DIB_RGB_COLORS = 0;
public BitmapInfoHeader(int width, int height, short bpp) {
biSize = (uint)Marshal.SizeOf(typeof(BitmapInfoHeader)); // BITMAPINFOHEADER is 40 bytes
biPlanes = 1; // Should allways be 1
biCompression = BI_RGB;
biWidth=width;
biHeight=height;
biBitCount=bpp;
biSizeImage = 0;
biXPelsPerMeter = 0;
biYPelsPerMeter = 0;
biClrUsed = 0;
biClrImportant = 0;
}
}
}

View file

@ -0,0 +1,58 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers {
[Flags]
public enum ThreadAccess : int {
TERMINATE = (0x0001),
SUSPEND_RESUME = (0x0002),
GET_CONTEXT = (0x0008),
SET_CONTEXT = (0x0010),
SET_INFORMATION = (0x0020),
QUERY_INFORMATION = (0x0040),
SET_THREAD_TOKEN = (0x0080),
IMPERSONATE = (0x0100),
DIRECT_IMPERSONATION = (0x0200)
}
/// <summary>
/// Description of Kernel32.
/// </summary>
public class Kernel32 {
public const uint ATTACHCONSOLE_ATTACHPARENTPROCESS = 0x0ffffffff; // default value if not specifing a process ID
[DllImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AttachConsole(uint dwProcessId);
[DllImport("kernel32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AllocConsole();
[DllImport("kernel32")]
public static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
[DllImport("kernel32")]
public static extern uint SuspendThread(IntPtr hThread);
[DllImport("kernel32")]
public static extern int ResumeThread(IntPtr hThread);
}
}

View file

@ -0,0 +1,33 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers {
/// <summary>
/// Description of Shell32.
/// </summary>
public static class Shell32 {
[DllImport("shell32")]
public static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
}
}

View file

@ -0,0 +1,42 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers {
[StructLayout(LayoutKind.Sequential), Serializable()]
public struct SIZE {
public int cx;
public int cy;
public SIZE(Size size) : this(size.Width, size.Height) {
}
public SIZE(int cx, int cy) {
this.cx = cx;
this.cy = cy;
}
public Size ToSize() {
return new Size(cx, cy);
}
}
}

View file

@ -0,0 +1,458 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
namespace GreenshotPlugin.UnmanagedHelpers {
public delegate int EnumWindowsProc(IntPtr hwnd, int lParam);
[StructLayout(LayoutKind.Sequential), Serializable()]
public struct POINT {
public int X;
public int Y;
public POINT(int x, int y) {
this.X = x;
this.Y = y;
}
public POINT(Point point) {
this.X = point.X;
this.Y = point.Y;
}
public static implicit operator System.Drawing.Point(POINT p) {
return new System.Drawing.Point(p.X, p.Y);
}
public static implicit operator POINT(System.Drawing.Point p) {
return new POINT(p.X, p.Y);
}
public Point ToPoint() {
return new Point(X, Y);
}
override public string ToString() {
return X +","+Y;
}
}
[StructLayout(LayoutKind.Sequential), Serializable()]
public struct RECT {
private int _Left;
private int _Top;
private int _Right;
private int _Bottom;
public RECT(RECT rectangle) : this(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom) {
}
public RECT(Rectangle rectangle) : this(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom) {
}
public RECT(int Left, int Top, int Right, int Bottom) {
_Left = Left;
_Top = Top;
_Right = Right;
_Bottom = Bottom;
}
public int X {
get { return _Left; }
set { _Left = value; }
}
public int Y {
get { return _Top; }
set { _Top = value; }
}
public int Left {
get { return _Left; }
set { _Left = value; }
}
public int Top {
get { return _Top; }
set { _Top = value; }
}
public int Right {
get { return _Right; }
set { _Right = value; }
}
public int Bottom {
get { return _Bottom; }
set { _Bottom = value; }
}
public int Height {
get { return _Bottom - _Top; }
set { _Bottom = value - _Top; }
}
public int Width {
get { return _Right - _Left; }
set { _Right = value + _Left; }
}
public Point Location {
get { return new Point(Left, Top); }
set {
_Left = value.X;
_Top = value.Y;
}
}
public Size Size {
get { return new Size(Width, Height); }
set {
_Right = value.Width + _Left;
_Bottom = value.Height + _Top;
}
}
public static implicit operator Rectangle(RECT Rectangle) {
return new Rectangle(Rectangle.Left, Rectangle.Top, Rectangle.Width, Rectangle.Height);
}
public static implicit operator RECT(Rectangle Rectangle) {
return new RECT(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom);
}
public static bool operator ==(RECT Rectangle1, RECT Rectangle2)
{
return Rectangle1.Equals(Rectangle2);
}
public static bool operator !=(RECT Rectangle1, RECT Rectangle2) {
return !Rectangle1.Equals(Rectangle2);
}
public override string ToString() {
return "{Left: " + _Left + "; " + "Top: " + _Top + "; Right: " + _Right + "; Bottom: " + _Bottom + "}";
}
public override int GetHashCode() {
return ToString().GetHashCode();
}
public bool Equals(RECT Rectangle) {
return Rectangle.Left == _Left && Rectangle.Top == _Top && Rectangle.Right == _Right && Rectangle.Bottom == _Bottom;
}
public Rectangle ToRectangle() {
return new Rectangle(Left, Top, Width, Height);
}
public override bool Equals(object Object) {
if (Object is RECT) {
return Equals((RECT)Object);
} else if (Object is Rectangle) {
return Equals(new RECT((Rectangle)Object));
}
return false;
}
}
[StructLayout(LayoutKind.Sequential), Serializable()]
public struct WindowInfo {
public uint cbSize;
public RECT rcWindow;
public RECT rcClient;
public uint dwStyle;
public uint dwExStyle;
public uint dwWindowStatus;
public uint cxWindowBorders;
public uint cyWindowBorders;
public ushort atomWindowType;
public ushort wCreatorVersion;
// Allows automatic initialization of "cbSize" with "new WINDOWINFO(null/true/false)".
public WindowInfo(Boolean ? filler) : this() {
cbSize = (UInt32)(Marshal.SizeOf(typeof( WindowInfo )));
}
}
/// <summary>
/// Contains information about the placement of a window on the screen.
/// </summary>
[StructLayout(LayoutKind.Sequential), Serializable()]
public struct WindowPlacement {
/// <summary>
/// The length of the structure, in bytes. Before calling the GetWindowPlacement or SetWindowPlacement functions, set this member to sizeof(WINDOWPLACEMENT).
/// <para>
/// GetWindowPlacement and SetWindowPlacement fail if this member is not set correctly.
/// </para>
/// </summary>
public int Length;
/// <summary>
/// Specifies flags that control the position of the minimized window and the method by which the window is restored.
/// </summary>
public WindowPlacementFlags Flags;
/// <summary>
/// The current show state of the window.
/// </summary>
public ShowWindowCommand ShowCmd;
/// <summary>
/// The coordinates of the window's upper-left corner when the window is minimized.
/// </summary>
public POINT MinPosition;
/// <summary>
/// The coordinates of the window's upper-left corner when the window is maximized.
/// </summary>
public POINT MaxPosition;
/// <summary>
/// The window's coordinates when the window is in the restored position.
/// </summary>
public RECT NormalPosition;
/// <summary>
/// Gets the default (empty) value.
/// </summary>
public static WindowPlacement Default {
get {
WindowPlacement result = new WindowPlacement();
result.Length = Marshal.SizeOf( result );
return result;
}
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CursorInfo {
public Int32 cbSize;
public Int32 flags;
public IntPtr hCursor;
public POINT ptScreenPos;
}
[StructLayout(LayoutKind.Sequential)]
public struct IconInfo {
public bool fIcon;
public Int32 xHotspot;
public Int32 yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColor;
}
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct SCROLLINFO {
public int cbSize;
public int fMask;
public int nMin;
public int nMax;
public int nPage;
public int nPos;
public int nTrackPos;
}
/// <summary>
/// User32 Wrappers
/// </summary>
public class User32 {
public const int WM_COMMAND = 0x111;
public const int WM_SYSCOMMAND = 0x112;
public const int SC_RESTORE = 0xF120;
public const int SC_CLOSE = 0xF060;
public const int SC_MAXIMIZE = 0xF030;
public const int SC_MINIMIZE = 0xF020;
public const int PW_DEFAULT = 0x00;
public const int PW_CLIENTONLY = 0x01;
/// <summary>
/// Stop flashing. The system restores the window to its original state.
/// </summary>
public const int FLASHW_STOP = 0;
/// <summary>
/// Flash the window caption.
/// </summary>
public const int FLASHW_CAPTION = 0x00000001;
/// <summary>
/// Flash the taskbar button.
/// </summary>
public const int FLASHW_TRAY = 0x00000002;
/// <summary>
/// Flash both the window caption and taskbar button.
/// </summary>
public const int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY);
/// <summary>
/// Flash continuously, until the FLASHW_STOP flag is set.
/// </summary>
public const int FLASHW_TIMER = 0x00000004;
/// <summary>
/// Flash continuously until the window comes to the foreground.
/// </summary>
public const int FLASHW_TIMERNOFG = 0x0000000C;
public const Int32 CURSOR_SHOWING = 0x00000001;
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public extern static bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, out IntPtr processId);
[DllImport("user32", SetLastError = true, ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetWindow(IntPtr hWnd, GetWindowCommand uCmd);
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int cch);
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
public extern static int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
public static extern uint GetSysColor(int nIndex);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool BringWindowToTop(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowPlacement(IntPtr hWnd, ref WindowPlacement lpwndpl);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WindowPlacement lpwndpl);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public extern static bool IsIconic(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public extern static bool IsZoomed(IntPtr hwnd);
[DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
public extern static int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
[DllImport("user32", SetLastError=true)]
public extern static int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32", SetLastError=true, EntryPoint = "SendMessageA")]
public static extern bool SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
[DllImport("user32", SetLastError=true)]
public extern static uint GetWindowLong(IntPtr hwnd, int index);
[DllImport("user32", SetLastError = true)]
public static extern int SetWindowLong(IntPtr hWnd, int index, uint styleFlags);
[DllImport("user32", EntryPoint="GetWindowLongPtr", SetLastError=true)]
public extern static IntPtr GetWindowLongPtr(IntPtr hwnd, int nIndex);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowInfo(IntPtr hwnd, ref WindowInfo pwi);
[DllImport("user32", SetLastError = true)]
public extern static int EnumWindows(EnumWindowsProc lpEnumFunc, int lParam);
[DllImport("user32", SetLastError = true)]
public extern static int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc lpEnumFunc, int lParam);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
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);
[DllImport("user32", SetLastError = true)]
public static extern int SetScrollPos(IntPtr hWnd, System.Windows.Forms.Orientation nBar, int nPos, bool bRedraw);
[DllImport("user32", SetLastError=true, EntryPoint = "PostMessageA")]
public static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
[DllImport("user32", SetLastError = true)]
public static extern RegionResult GetWindowRgn(IntPtr hWnd, IntPtr hRgn);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDC);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, WindowPos uFlags);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetTopWindow(IntPtr hWnd);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32", SetLastError = true)]
public static extern void ReleaseDC(IntPtr dc);
[DllImport("user32", SetLastError = true)]
public static extern IntPtr GetClipboardOwner();
[DllImport("user32", SetLastError = true)]
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
[DllImport("user32", SetLastError = true)]
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
/// uiFlags: 0 - Count of GDI objects
/// uiFlags: 1 - Count of USER objects
/// - Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers)
/// - Win32 USER objects:
/// - WIN32 resources (accelerator tables, bitmap resources, dialog box templates, font resources, menu resources, raw data resources, string table entries, message table entries, cursors/icons)
/// - Other USER objects (windows, menus)
///
[DllImport("user32", SetLastError = true)]
public static extern uint GetGuiResources(IntPtr hProcess, uint uiFlags);
public static uint GetGuiResourcesGDICount() {
return GetGuiResources(Process.GetCurrentProcess().Handle, 0);
}
public static uint GetGuiResourcesUserCount() {
return GetGuiResources(Process.GetCurrentProcess().Handle, 1);
}
[DllImport("user32", EntryPoint = "RegisterWindowMessageA", SetLastError = true)]
public static extern uint RegisterWindowMessage(string lpString);
[DllImport("user32", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult);
/// <summary>
/// Helper method to create a Win32 exception with the windows message in it
/// </summary>
/// <param name="method">string with current method</param>
/// <returns>Exception</returns>
public static Exception CreateWin32Exception(string method) {
Win32Exception exceptionToThrow = new Win32Exception();
exceptionToThrow.Data.Add("Method", method);
return exceptionToThrow;
}
[DllImport("user32", SetLastError = true)]
public static extern bool GetPhysicalCursorPos(out POINT cursorLocation);
[DllImport("user32", SetLastError=true)]
public static extern int MapWindowPoints(IntPtr hwndFrom, IntPtr hwndTo, ref POINT lpPoints, [MarshalAs(UnmanagedType.U4)] int cPoints);
#region icon
[DllImport("user32", SetLastError = true)]
public static extern IntPtr CopyIcon(IntPtr hIcon);
[DllImport("user32", SetLastError = true)]
public static extern bool DestroyIcon(IntPtr hIcon);
[DllImport("user32", SetLastError = true)]
public static extern bool GetCursorInfo(out CursorInfo cursorInfo);
[DllImport("user32", SetLastError = true)]
public static extern bool GetIconInfo(IntPtr hIcon, out IconInfo iconInfo);
[DllImport("user32", SetLastError = true)]
public static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon);
#endregion
}
}

View file

@ -0,0 +1,140 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Runtime.InteropServices;
using System.Text;
/// <summary>
/// Win32 error codes
/// </summary>
namespace GreenshotPlugin.UnmanagedHelpers {
/// <summary>
/// A Win32 error code.
/// </summary>
public enum Win32Error : uint {
Success = 0x0,
InvalidFunction = 0x1,
FileNotFound = 0x2,
PathNotFound = 0x3,
TooManyOpenFiles = 0x4,
AccessDenied = 0x5,
InvalidHandle = 0x6,
ArenaTrashed = 0x7,
NotEnoughMemory = 0x8,
InvalidBlock = 0x9,
BadEnvironment = 0xa,
BadFormat = 0xb,
InvalidAccess = 0xc,
InvalidData = 0xd,
OutOfMemory = 0xe,
InvalidDrive = 0xf,
CurrentDirectory = 0x10,
NotSameDevice = 0x11,
NoMoreFiles = 0x12,
WriteProtect = 0x13,
BadUnit = 0x14,
NotReady = 0x15,
BadCommand = 0x16,
Crc = 0x17,
BadLength = 0x18,
Seek = 0x19,
NotDosDisk = 0x1a,
SectorNotFound = 0x1b,
OutOfPaper = 0x1c,
WriteFault = 0x1d,
ReadFault = 0x1e,
GenFailure = 0x1f,
SharingViolation = 0x20,
LockViolation = 0x21,
WrongDisk = 0x22,
SharingBufferExceeded = 0x24,
HandleEof = 0x26,
HandleDiskFull = 0x27,
NotSupported = 0x32,
RemNotList = 0x33,
DupName = 0x34,
BadNetPath = 0x35,
NetworkBusy = 0x36,
DevNotExist = 0x37,
TooManyCmds = 0x38,
FileExists = 0x50,
CannotMake = 0x52,
AlreadyAssigned = 0x55,
InvalidPassword = 0x56,
InvalidParameter = 0x57,
NetWriteFault = 0x58,
NoProcSlots = 0x59,
TooManySemaphores = 0x64,
ExclSemAlreadyOwned = 0x65,
SemIsSet = 0x66,
TooManySemRequests = 0x67,
InvalidAtInterruptTime = 0x68,
SemOwnerDied = 0x69,
SemUserLimit = 0x6a
}
public static class Win32 {
[DllImport("kernel32.dll")]
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, int nSize, IntPtr Arguments);
[DllImport("kernel32.dll")]
public static extern void SetLastError(uint dwErrCode);
public static Win32Error GetLastErrorCode() {
return (Win32Error)Marshal.GetLastWin32Error();
}
public static long GetHResult(Win32Error errorCode) {
int error = (int)errorCode;
if ((error & 0x80000000) == 0x80000000) {
return (long)error;
}
return (long)(0x80070000 | (uint)(error & 0xffff));
}
public static string GetMessage(Win32Error errorCode) {
StringBuilder buffer = new StringBuilder(0x100);
if (FormatMessage(0x3200, IntPtr.Zero, (uint)errorCode, 0, buffer, buffer.Capacity, IntPtr.Zero) == 0) {
return "Unknown error (0x" + ((int)errorCode).ToString("x") + ")";
}
StringBuilder result = new StringBuilder();
int i = 0;
while (i < buffer.Length) {
if (!char.IsLetterOrDigit(buffer[i]) &&
!char.IsPunctuation(buffer[i]) &&
!char.IsSymbol(buffer[i]) &&
!char.IsWhiteSpace(buffer[i]))
break;
result.Append(buffer[i]);
i++;
}
return result.ToString().Replace("\r\n", "");
}
}
}

View file

@ -0,0 +1,35 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* 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 1 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, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers {
/// <summary>
/// Windows Media
/// </summary>
public class WinMM {
[DllImport("winmm.dll", SetLastError = true)]
public static extern bool PlaySound(byte[] ptrToSound, System.UIntPtr hmod, uint fdwSound);
[DllImport("winmm.dll", SetLastError = true)]
public static extern bool PlaySound(IntPtr ptrToSound, System.UIntPtr hmod, uint fdwSound);
}
}