+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
-using System.Runtime.InteropServices;\r
-using System.Drawing;\r
-\r
-namespace FDK\r
-{\r
- public class CWin32\r
- {\r
- #region [ Win32 定数 ]\r
- //-----------------\r
- public const int S_OK = 0x00000000;\r
- public const int S_FALSE = 0x00000001;\r
- public const int E_FAIL = unchecked( (int) 0x80004005 );\r
- public const int E_ABORT = unchecked( (int) 0x80004004 );\r
-\r
- public const int BROADCAST_QUERY_DENY = 0x424d5144;\r
- \r
- public const uint CALLBACK_FUNCTION = 0x30000;\r
- public const uint ES_CONTINUOUS = 0x80000000;\r
- public const uint ES_DISPLAY_REQUIRED = 2;\r
- public const uint ES_SYSTEM_REQUIRED = 1;\r
- public const uint ES_USER_PRESENT = 4;\r
-\r
- public const int GWL_EXSTYLE = -20;\r
- public const int GWL_HINSTANCE = -6;\r
- public const int GWL_HWNDPARENT = -8;\r
- public const int GWL_ID = -12;\r
- public const int GWL_STYLE = -16;\r
- public const int GWL_USERDATA = -21;\r
- public const int GWL_WNDPROC = -4;\r
-\r
- public static readonly IntPtr HWND_NOTOPMOST = new IntPtr( -2 );\r
- public static readonly IntPtr HWND_TOPMOST = new IntPtr( -1 );\r
- public const uint MAXPNAMELEN = 0x20;\r
-\r
- #region [ MIDIメッセージ ]\r
- public const uint MIM_CLOSE = 0x3c2;\r
- public const uint MIM_DATA = 0x3c3;\r
- public const uint MIM_ERROR = 0x3c5;\r
- public const uint MIM_LONGDATA = 0x3c4;\r
- public const uint MIM_LONGERROR = 0x3c6;\r
- public const uint MIM_OPEN = 0x3c1;\r
- #endregion\r
-\r
- public const int MONITOR_DEFAULTTOPRIMARY = 1;\r
-\r
- public const int PBT_APMQUERYSTANDBY = 1;\r
- public const int PBT_APMQUERYSUSPEND = 0;\r
-\r
- public const int SC_MONITORPOWER = 0xf170;\r
- public const int SC_SCREENSAVE = 0xf140;\r
-\r
- public const int SIZE_MAXIMIZED = 2;\r
- public const int SIZE_MINIMIZED = 1;\r
- public const int SIZE_RESTORED = 0;\r
-\r
- public const uint SWP_FRAMECHANGED = 0x20;\r
- public const uint SWP_HIDEWINDOW = 0x80;\r
- public const uint SWP_NOACTIVATE = 0x10;\r
- public const uint SWP_NOCOPYBITS = 0x100;\r
- public const uint SWP_NOMOVE = 2;\r
- public const uint SWP_NOOWNERZORDER = 0x200;\r
- public const uint SWP_NOREDRAW = 8;\r
- public const uint SWP_NOSENDCHANGING = 0x400;\r
- public const uint SWP_NOSIZE = 1;\r
- public const uint SWP_NOZORDER = 4;\r
- public const uint SWP_SHOWWINDOW = 0x40;\r
-\r
- public const uint PM_NOREMOVE = 0;\r
- public const uint PM_REMOVE = 1;\r
-\r
- #region [ DirectShow, VFW 関連 ]\r
- //-----------------\r
- public const int S_WARN_OUTPUTRESET = 0x00009DD4;\r
- public const int E_NOTINTREE = unchecked( (int) 0x80040400 );\r
- public const int E_RENDER_ENGINE_IS_BROKEN = unchecked( (int) 0x80040401 );\r
- public const int E_MUST_INIT_RENDERER = unchecked( (int) 0x80040402 );\r
- public const int E_NOTDETERMINED = unchecked( (int) 0x80040403 );\r
- public const int E_NO_TIMELINE = unchecked( (int) 0x80040404 );\r
-\r
- public const int VFW_E_INVALIDMEDIATYPE = unchecked( (int) 0x80040200 );\r
- public const int VFW_E_INVALIDSUBTYPE = unchecked( (int) 0x80040201 );\r
- public const int VFW_E_NEED_OWNER = unchecked( (int) 0x80040202 );\r
- public const int VFW_E_ENUM_OUT_OF_SYNC = unchecked( (int) 0x80040203 );\r
- public const int VFW_E_ALREADY_CONNECTED = unchecked( (int) 0x80040204 );\r
- public const int VFW_E_FILTER_ACTIVE = unchecked( (int) 0x80040205 );\r
- public const int VFW_E_NO_TYPES = unchecked( (int) 0x80040206 );\r
- public const int VFW_E_NO_ACCEPTABLE_TYPES = unchecked( (int) 0x80040207 );\r
- public const int VFW_E_INVALID_DIRECTION = unchecked( (int) 0x80040208 );\r
- public const int VFW_E_NOT_CONNECTED = unchecked( (int) 0x80040209 );\r
- public const int VFW_E_NO_ALLOCATOR = unchecked( (int) 0x8004020A );\r
- public const int VFW_E_RUNTIME_ERROR = unchecked( (int) 0x8004020B );\r
- public const int VFW_E_BUFFER_NOTSET = unchecked( (int) 0x8004020C );\r
- public const int VFW_E_BUFFER_OVERFLOW = unchecked( (int) 0x8004020D );\r
- public const int VFW_E_BADALIGN = unchecked( (int) 0x8004020E );\r
- public const int VFW_E_ALREADY_COMMITTED = unchecked( (int) 0x8004020F );\r
- public const int VFW_E_BUFFERS_OUTSTANDING = unchecked( (int) 0x80040210 );\r
- public const int VFW_E_NOT_COMMITTED = unchecked( (int) 0x80040211 );\r
- public const int VFW_E_SIZENOTSET = unchecked( (int) 0x80040212 );\r
- public const int VFW_E_NO_CLOCK = unchecked( (int) 0x80040213 );\r
- public const int VFW_E_NO_SINK = unchecked( (int) 0x80040214 );\r
- public const int VFW_E_NO_INTERFACE = unchecked( (int) 0x80040215 );\r
- public const int VFW_E_NOT_FOUND = unchecked( (int) 0x80040216 );\r
- public const int VFW_E_CANNOT_CONNECT = unchecked( (int) 0x80040217 );\r
- public const int VFW_E_CANNOT_RENDER = unchecked( (int) 0x80040218 );\r
- public const int VFW_E_CHANGING_FORMAT = unchecked( (int) 0x80040219 );\r
- public const int VFW_E_NO_COLOR_KEY_SET = unchecked( (int) 0x8004021A );\r
- public const int VFW_E_NOT_OVERLAY_CONNECTION = unchecked( (int) 0x8004021B );\r
- public const int VFW_E_NOT_SAMPLE_CONNECTION = unchecked( (int) 0x8004021C );\r
- public const int VFW_E_PALETTE_SET = unchecked( (int) 0x8004021D );\r
- public const int VFW_E_COLOR_KEY_SET = unchecked( (int) 0x8004021E );\r
- public const int VFW_E_NO_COLOR_KEY_FOUND = unchecked( (int) 0x8004021F );\r
- public const int VFW_E_NO_PALETTE_AVAILABLE = unchecked( (int) 0x80040220 );\r
- public const int VFW_E_NO_DISPLAY_PALETTE = unchecked( (int) 0x80040221 );\r
- public const int VFW_E_TOO_MANY_COLORS = unchecked( (int) 0x80040222 );\r
- public const int VFW_E_STATE_CHANGED = unchecked( (int) 0x80040223 );\r
- public const int VFW_E_NOT_STOPPED = unchecked( (int) 0x80040224 );\r
- public const int VFW_E_NOT_PAUSED = unchecked( (int) 0x80040225 );\r
- public const int VFW_E_NOT_RUNNING = unchecked( (int) 0x80040226 );\r
- public const int VFW_E_WRONG_STATE = unchecked( (int) 0x80040227 );\r
- public const int VFW_E_START_TIME_AFTER_END = unchecked( (int) 0x80040228 );\r
- public const int VFW_E_INVALID_RECT = unchecked( (int) 0x80040229 );\r
- public const int VFW_E_TYPE_NOT_ACCEPTED = unchecked( (int) 0x8004022A );\r
- public const int VFW_E_SAMPLE_REJECTED = unchecked( (int) 0x8004022B );\r
- public const int VFW_E_SAMPLE_REJECTED_EOS = unchecked( (int) 0x8004022C );\r
- public const int VFW_E_DUPLICATE_NAME = unchecked( (int) 0x8004022D );\r
- public const int VFW_S_DUPLICATE_NAME = 0x0004022D;\r
- public const int VFW_E_TIMEOUT = unchecked( (int) 0x8004022E );\r
- public const int VFW_E_INVALID_FILE_FORMAT = unchecked( (int) 0x8004022F );\r
- public const int VFW_E_ENUM_OUT_OF_RANGE = unchecked( (int) 0x80040230 );\r
- public const int VFW_E_CIRCULAR_GRAPH = unchecked( (int) 0x80040231 );\r
- public const int VFW_E_NOT_ALLOWED_TO_SAVE = unchecked( (int) 0x80040232 );\r
- public const int VFW_E_TIME_ALREADY_PASSED = unchecked( (int) 0x80040233 );\r
- public const int VFW_E_ALREADY_CANCELLED = unchecked( (int) 0x80040234 );\r
- public const int VFW_E_CORRUPT_GRAPH_FILE = unchecked( (int) 0x80040235 );\r
- public const int VFW_E_ADVISE_ALREADY_SET = unchecked( (int) 0x80040236 );\r
- public const int VFW_S_STATE_INTERMEDIATE = 0x00040237;\r
- public const int VFW_E_NO_MODEX_AVAILABLE = unchecked( (int) 0x80040238 );\r
- public const int VFW_E_NO_ADVISE_SET = unchecked( (int) 0x80040239 );\r
- public const int VFW_E_NO_FULLSCREEN = unchecked( (int) 0x8004023A );\r
- public const int VFW_E_IN_FULLSCREEN_MODE = unchecked( (int) 0x8004023B );\r
- public const int VFW_E_UNKNOWN_FILE_TYPE = unchecked( (int) 0x80040240 );\r
- public const int VFW_E_CANNOT_LOAD_SOURCE_FILTER = unchecked( (int) 0x80040241 );\r
- public const int VFW_S_PARTIAL_RENDER = 0x00040242;\r
- public const int VFW_E_FILE_TOO_SHORT = unchecked( (int) 0x80040243 );\r
- public const int VFW_E_INVALID_FILE_VERSION = unchecked( (int) 0x80040244 );\r
- public const int VFW_S_SOME_DATA_IGNORED = 0x00040245;\r
- public const int VFW_S_CONNECTIONS_DEFERRED = 0x00040246;\r
- public const int VFW_E_INVALID_CLSID = unchecked( (int) 0x80040247 );\r
- public const int VFW_E_INVALID_MEDIA_TYPE = unchecked( (int) 0x80040248 );\r
- public const int VFW_E_SAMPLE_TIME_NOT_SET = unchecked( (int) 0x80040249 );\r
- public const int VFW_S_RESOURCE_NOT_NEEDED = 0x00040250;\r
- public const int VFW_E_MEDIA_TIME_NOT_SET = unchecked( (int) 0x80040251 );\r
- public const int VFW_E_NO_TIME_FORMAT_SET = unchecked( (int) 0x80040252 );\r
- public const int VFW_E_MONO_AUDIO_HW = unchecked( (int) 0x80040253 );\r
- public const int VFW_S_MEDIA_TYPE_IGNORED = 0x00040254;\r
- public const int VFW_E_NO_DECOMPRESSOR = unchecked( (int) 0x80040255 );\r
- public const int VFW_E_NO_AUDIO_HARDWARE = unchecked( (int) 0x80040256 );\r
- public const int VFW_S_VIDEO_NOT_RENDERED = 0x00040257;\r
- public const int VFW_S_AUDIO_NOT_RENDERED = 0x00040258;\r
- public const int VFW_E_RPZA = unchecked( (int) 0x80040259 );\r
- public const int VFW_S_RPZA = 0x0004025A;\r
- public const int VFW_E_PROCESSOR_NOT_SUITABLE = unchecked( (int) 0x8004025B );\r
- public const int VFW_E_UNSUPPORTED_AUDIO = unchecked( (int) 0x8004025C );\r
- public const int VFW_E_UNSUPPORTED_VIDEO = unchecked( (int) 0x8004025D );\r
- public const int VFW_E_MPEG_NOT_CONSTRAINED = unchecked( (int) 0x8004025E );\r
- public const int VFW_E_NOT_IN_GRAPH = unchecked( (int) 0x8004025F );\r
- public const int VFW_S_ESTIMATED = 0x00040260;\r
- public const int VFW_E_NO_TIME_FORMAT = unchecked( (int) 0x80040261 );\r
- public const int VFW_E_READ_ONLY = unchecked( (int) 0x80040262 );\r
- public const int VFW_S_RESERVED = 0x00040263;\r
- public const int VFW_E_BUFFER_UNDERFLOW = unchecked( (int) 0x80040264 );\r
- public const int VFW_E_UNSUPPORTED_STREAM = unchecked( (int) 0x80040265 );\r
- public const int VFW_E_NO_TRANSPORT = unchecked( (int) 0x80040266 );\r
- public const int VFW_S_STREAM_OFF = 0x00040267;\r
- public const int VFW_S_CANT_CUE = 0x00040268;\r
- public const int VFW_E_BAD_VIDEOCD = unchecked( (int) 0x80040269 );\r
- public const int VFW_S_NO_STOP_TIME = 0x00040270;\r
- public const int VFW_E_OUT_OF_VIDEO_MEMORY = unchecked( (int) 0x80040271 );\r
- public const int VFW_E_VP_NEGOTIATION_FAILED = unchecked( (int) 0x80040272 );\r
- public const int VFW_E_DDRAW_CAPS_NOT_SUITABLE = unchecked( (int) 0x80040273 );\r
- public const int VFW_E_NO_VP_HARDWARE = unchecked( (int) 0x80040274 );\r
- public const int VFW_E_NO_CAPTURE_HARDWARE = unchecked( (int) 0x80040275 );\r
- public const int VFW_E_DVD_OPERATION_INHIBITED = unchecked( (int) 0x80040276 );\r
- public const int VFW_E_DVD_INVALIDDOMAIN = unchecked( (int) 0x80040277 );\r
- public const int VFW_E_DVD_NO_BUTTON = unchecked( (int) 0x80040278 );\r
- public const int VFW_E_DVD_GRAPHNOTREADY = unchecked( (int) 0x80040279 );\r
- public const int VFW_E_DVD_RENDERFAIL = unchecked( (int) 0x8004027A );\r
- public const int VFW_E_DVD_DECNOTENOUGH = unchecked( (int) 0x8004027B );\r
- public const int VFW_E_DVD_NOT_IN_KARAOKE_MODE = unchecked( (int) 0x8004028B );\r
- public const int VFW_E_FRAME_STEP_UNSUPPORTED = unchecked( (int) 0x8004028E );\r
- public const int VFW_E_PIN_ALREADY_BLOCKED_ON_THIS_THREAD = unchecked( (int) 0x80040293 );\r
- public const int VFW_E_PIN_ALREADY_BLOCKED = unchecked( (int) 0x80040294 );\r
- public const int VFW_E_CERTIFICATION_FAILURE = unchecked( (int) 0x80040295 );\r
- public const int VFW_E_BAD_KEY = unchecked( (int) 0x800403F2 );\r
- //-----------------\r
- #endregion\r
-\r
- #region [ Windowsメッセージ ]\r
- public const uint WM_ACTIVATEAPP = 0x1c;\r
- public const uint WM_COPYDATA = 0x4a;\r
- public const uint WM_CLOSE = 0x10;\r
- public const uint WM_POWERBROADCAST = 0x218;\r
- public const uint WM_SIZE = 5;\r
- public const uint WM_SYSCOMMAND = 0x112;\r
- public const uint WM_SYSKEYDOWN = 260;\r
- public const uint WM_APP = 0x00008000;\r
- public const uint WM_QUIT = 0x12;\r
- public const uint WPF_RESTORETOMAXIMIZED = 2;\r
- #endregion\r
-\r
- #region [ WindowsStyle フラグ]\r
- public const long WS_BORDER = 0x800000L;\r
- public const long WS_CAPTION = 0xc00000L;\r
- public const long WS_CHILD = 0x40000000L;\r
- public const long WS_CHILDWINDOW = 0x40000000L;\r
- public const long WS_CLIPCHILDREN = 0x2000000L;\r
- public const long WS_CLIPSIBLINGS = 0x4000000L;\r
- public const long WS_DISABLED = 0x8000000L;\r
- public const long WS_DLGFRAME = 0x400000L;\r
- public const long WS_GROUP = 0x20000L;\r
- public const long WS_HSCROLL = 0x100000L;\r
- public const long WS_ICONIC = 0x20000000L;\r
- public const long WS_MAXIMIZE = 0x1000000L;\r
- public const long WS_MAXIMIZEBOX = 0x10000L;\r
- public const long WS_MINIMIZE = 0x20000000L;\r
- public const long WS_MINIMIZEBOX = 0x20000L;\r
- public const long WS_OVERLAPPED = 0L;\r
- public const long WS_OVERLAPPEDWINDOW = 0xcf0000L;\r
- public const long WS_POPUP = 0x80000000L;\r
- public const long WS_POPUPWINDOW = 0x80880000L;\r
- public const long WS_SIZEBOX = 0x40000L;\r
- public const long WS_SYSMENU = 0x80000L;\r
- public const long WS_TABSTOP = 0x10000L;\r
- public const long WS_THICKFRAME = 0x40000L;\r
- public const long WS_TILED = 0L;\r
- public const long WS_TILEDWINDOW = 0xcf0000L;\r
- public const long WS_VISIBLE = 0x10000000L;\r
- public const long WS_VSCROLL = 0x200000L;\r
- public const long WS_EX_ACCEPTFILES = 0x10L;\r
- public const long WS_EX_APPWINDOW = 0x40000L;\r
- public const long WS_EX_CLIENTEDGE = 0x200L;\r
- public const long WS_EX_COMPOSITED = 0x2000000L;\r
- public const long WS_EX_CONTEXTHELP = 0x400L;\r
- public const long WS_EX_CONTROLPARENT = 0x10000L;\r
- public const long WS_EX_DLGMODALFRAME = 1L;\r
- public const long WS_EX_LAYERED = 0x80000L;\r
- public const long WS_EX_LAYOUTRTL = 0x400000L;\r
- public const long WS_EX_LEFT = 0L;\r
- public const long WS_EX_LEFTSCROLLBAR = 0x4000L;\r
- public const long WS_EX_LTRREADING = 0L;\r
- public const long WS_EX_MDICHILD = 0x40L;\r
- public const long WS_EX_NOACTIVATE = 0x8000000L;\r
- public const long WS_EX_NOINHERITLAYOUT = 0x100000L;\r
- public const long WS_EX_NOPARENTNOTIFY = 4L;\r
- public const long WS_EX_OVERLAPPEDWINDOW = 0x300L;\r
- public const long WS_EX_PALETTEWINDOW = 0x188L;\r
- public const long WS_EX_RIGHT = 0x1000L;\r
- public const long WS_EX_RIGHTSCROLLBAR = 0L;\r
- public const long WS_EX_RTLREADING = 0x2000L;\r
- public const long WS_EX_STATICEDGE = 0x20000L;\r
- public const long WS_EX_TOOLWINDOW = 0x80L;\r
- public const long WS_EX_TOPMOST = 8L;\r
- public const long WS_EX_TRANSPARENT = 0x20L;\r
- public const long WS_EX_WINDOWEDGE = 0x100L;\r
- #endregion\r
-\r
-\r
- public enum EShowWindow\r
- {\r
- ForceMinimize = 11,\r
- Hide = 0,\r
- Maximize = 3,\r
- Minimize = 6,\r
- Normal = 1,\r
- Restore = 9,\r
- Show = 5,\r
- ShowDefault = 10,\r
- ShowMaximized = 3,\r
- ShowMinimized = 2,\r
- ShowMinNoActive = 7,\r
- ShowNA = 8,\r
- ShowNoActivate = 4\r
- }\r
- public enum MMSYSERR\r
- {\r
- NOERROR,\r
- ERROR,\r
- BADDEVICEID,\r
- NOTENABLED,\r
- ALLOCATED,\r
- INVALHANDLE,\r
- NODRIVER,\r
- NOMEM,\r
- NOTSUPPORTED,\r
- BADERRNUM,\r
- INVALFLAG,\r
- INVALPARAM,\r
- HANDLEBUSY,\r
- INVALIDALIAS,\r
- BADDB,\r
- KEYNOTFOUND,\r
- READERROR,\r
- WRITEERROR,\r
- DELETEERROR,\r
- VALNOTFOUND,\r
- NODRIVERCB,\r
- MOREDATA\r
- }\r
- [FlagsAttribute]\r
- internal enum ExecutionState : uint\r
- {\r
- Null = 0, // 関数が失敗した時の戻り値\r
- SystemRequired = 1, // スタンバイを抑止\r
- DisplayRequired = 2, // 画面OFFを抑止\r
- Continuous = 0x80000000, // 効果を永続させる。ほかオプションと併用する。\r
- }\r
- //-----------------\r
- #endregion\r
-\r
- #region [ Win32 関数 ]\r
- //-----------------\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern bool AdjustWindowRect( ref RECT lpRect, uint dwStyle, [MarshalAs( UnmanagedType.Bool )] bool bMenu );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern bool GetClientRect( IntPtr hWnd, out RECT lpRect );\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern uint GetWindowLong( IntPtr hWnd, int nIndex );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern bool GetWindowPlacement( IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
- public static extern bool IsIconic( IntPtr hWnd );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
- public static extern bool IsWindowVisible( IntPtr hWnd );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
- public static extern bool IsZoomed( IntPtr hWnd );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInClose( uint hMidiIn );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInGetDevCaps( uint uDeviceID, ref MIDIINCAPS lpMidiInCaps, uint cbMidiInCaps );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInGetID( uint hMidiIn, ref uint puDeviceID );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInGetNumDevs();\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInOpen( ref uint phMidiIn, uint uDeviceID, MidiInProc dwCallback, int dwInstance, int fdwOpen );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInReset( uint hMidiIn );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInStart( uint hMidiIn );\r
- [DllImport( "winmm.dll" )]\r
- public static extern uint midiInStop( uint hMidiIn );\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
- public static extern IntPtr MonitorFromWindow( IntPtr hwnd, uint dwFlags );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
- public static extern bool PeekMessage( out WindowMessage message, IntPtr hwnd, uint messageFilterMin, uint messageFilterMax, uint flags );\r
- //[DllImport( "kernel32.dll", CharSet = CharSet.Auto )]\r
- //public static extern uint SetThreadExecutionState( uint esFlags );\r
- [DllImport( "Kernel32.Dll" )]\r
- public static unsafe extern void CopyMemory( void* pDest, void* pSrc, uint numOfBytes );\r
-\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern uint SetWindowLong( IntPtr hWnd, int nIndex, uint dwNewLong );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern bool SetWindowPlacement( IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto )]\r
- public static extern bool ShowWindow( IntPtr hWnd, EShowWindow nCmdShow );\r
- [return: MarshalAs( UnmanagedType.Bool )]\r
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]\r
- public static extern bool SystemParametersInfo( uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni );\r
- [DllImport( "kernel32.dll" )]\r
- public static extern void GetSystemInfo( ref SYSTEM_INFO ptmpsi );\r
- [DllImport( "kernel32.dll" )]\r
- internal static extern ExecutionState SetThreadExecutionState( ExecutionState esFlags );\r
-\r
- \r
- [DllImport("PowrProf.dll")]\r
- public static extern UInt32 PowerEnumerate(IntPtr RootPowerKey, IntPtr SchemeGuid, IntPtr SubGroupOfPowerSettingGuid, UInt32 AcessFlags, UInt32 Index, ref Guid Buffer, ref UInt32 BufferSize);\r
- public enum AccessFlags : uint\r
- {\r
- ACCESS_SCHEME = 16,\r
- ACCESS_SUBGROUP = 17,\r
- ACCESS_INDIVIDUAL_SETTING = 18\r
- }\r
- [DllImport( "PowrProf.dll" )]\r
- public static extern UInt32 PowerReadFriendlyName( IntPtr RootPowerKey, ref Guid SchemeGuid, IntPtr SubGroupOfPowerSettingGuid, IntPtr PowerSettingGuid, IntPtr Buffer, ref UInt32 BufferSize );\r
- [DllImport( "PowrProf.dll" )]\r
- public static extern uint PowerGetActiveScheme( IntPtr UserRootPowerKey, ref IntPtr ActivePolicyGuid );\r
- [DllImport( "PowrProf.dll" )]\r
- public static extern uint PowerSetActiveScheme(IntPtr UserRootPowerKey, ref Guid SchemeGuid);\r
- [DllImport( "powrprof.dll" )]\r
- public static extern uint CallNtPowerInformation(\r
- int InformationLevel,\r
- IntPtr lpInputBuffer,\r
- int nInputBufferSize,\r
- out SYSTEM_POWER_CAPABILITIES spi,\r
- int nOutputBufferSize\r
- );\r
-\r
-\r
- //-----------------\r
- #endregion\r
-\r
- #region [ Win32 構造体 ]\r
- //-----------------\r
- [StructLayout( LayoutKind.Sequential )]\r
- private struct FILTERKEYS\r
- {\r
- public int cbSize;\r
- public int dwFlags;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- public struct MIDIINCAPS\r
- {\r
- public ushort wMid;\r
- public ushort wPid;\r
- public uint vDriverVersion;\r
- [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 0x20 )]\r
- public string szPname;\r
- public uint dwSupport;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- public struct RECT\r
- {\r
- public int left;\r
- public int top;\r
- public int right;\r
- public int bottom;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- private struct STICKYKEYS\r
- {\r
- public int cbSize;\r
- public int dwFlags;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- private struct TOGGLEKEYS\r
- {\r
- public int cbSize;\r
- public int dwFlags;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- public struct WAVEFORMATEX\r
- {\r
- public ushort wFormatTag;\r
- public ushort nChannels;\r
- public uint nSamplesPerSec;\r
- public uint nAvgBytesPerSec;\r
- public ushort nBlockAlign;\r
- public ushort wBitsPerSample;\r
- public ushort cbSize;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- public struct WindowMessage\r
- {\r
- public IntPtr hWnd;\r
- public uint msg;\r
- public IntPtr wParam;\r
- public IntPtr lParam;\r
- public uint time;\r
- public Point p;\r
- }\r
-\r
- [StructLayout( LayoutKind.Sequential )]\r
- public struct WINDOWPLACEMENT\r
- {\r
- public int length;\r
- public int flags;\r
- public CWin32.EShowWindow showCmd;\r
- public Point ptMinPosition;\r
- public Point ptMaxPosition;\r
- public CWin32.RECT rcNormalPosition;\r
- public static int Length\r
- {\r
- get\r
- {\r
- return Marshal.SizeOf( typeof( CWin32.WINDOWPLACEMENT ) );\r
- }\r
- }\r
- }\r
- [StructLayout( LayoutKind.Sequential )]\r
- public struct SYSTEM_INFO\r
- {\r
- public uint dwOemId;\r
- public uint dwPageSize;\r
- public uint lpMinimumApplicationAddress;\r
- public uint lpMaximumApplicationAddress;\r
- public uint dwActiveProcessorMask;\r
- public uint dwNumberOfProcessors;\r
- public uint dwProcessorType;\r
- public uint dwAllocationGranularity;\r
- public uint dwProcessorLevel;\r
- public uint dwProcessorRevision;\r
- }\r
- public struct BATTERY_REPORTING_SCALE\r
- {\r
- public ulong Granularity;\r
- public ulong Capacity;\r
- }\r
- public enum SYSTEM_POWER_STATE\r
- {\r
- PowerSystemUnspecified = 0,\r
- PowerSystemWorking = 1,\r
- PowerSystemSleeping1 = 2,\r
- PowerSystemSleeping2 = 3,\r
- PowerSystemSleeping3 = 4,\r
- PowerSystemHibernate = 5,\r
- PowerSystemShutdown = 6,\r
- PowerSystemMaximum = 7\r
- }\r
- public struct SYSTEM_POWER_INFORMATION\r
- {\r
- public uint MaxIdlenessAllowed;\r
- public uint Idleness;\r
- public uint TimeRemaining;\r
- public byte CoolingMode;\r
- }\r
- public enum POWER_INFORMATION_LEVEL : int\r
- {\r
- AdministratorPowerPolicy = 9,\r
- LastSleepTime1 = 5,\r
- LastWakeTime = 14,\r
- ProcessorInformation = 11,\r
- ProcessorPowerPolicyAc = 18,\r
- ProcessorPowerPolicyCurrent = 22,\r
- ProcessorPowerPolicyDc = 19,\r
- SystemBatteryState = 5,\r
- SystemExecutionState = 16,\r
- SystemPowerCapabilities = 4,\r
- SystemPowerInformation = 12,\r
- SystemPowerPolicyAc = 0,\r
- SystemPowerPolicyCurrent = 8,\r
- SystemPowerPolicyDc = 1,\r
- SystemReserveHiberFile = 10,\r
- VerifyProcessorPowerPolicyAc = 20,\r
- VerifyProcessorPowerPolicyDc = 21,\r
- VerifySystemPolicyAc = 2,\r
- VerifySystemPolicyDc = 3\r
- }\r
-\r
- // http://www.pinvoke.net/default.aspx/Structures/SYSTEM_POWER_STATE.html\r
- public struct SYSTEM_POWER_CAPABILITIES\r
- {\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool PowerButtonPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SleepButtonPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool LidPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SystemS1;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SystemS2;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SystemS3;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SystemS4;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SystemS5;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool HiberFilePresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool FullWake;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool VideoDimPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool ApmPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool UpsPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool ThermalControl;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool ProcessorThrottle;\r
- public byte ProcessorMinThrottle;\r
- public byte ProcessorMaxThrottle; // Also known as ProcessorThrottleScale before Windows XP\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool FastSystemS4; // Ignore if earlier than Windows XP\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool Hiberboot; // Ignore if earlier than Windows XP\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool WakeAlarmPresent; // Ignore if earlier than Windows XP\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool AoAc; // Ignore if earlier than Windows XP\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool DiskSpinDown;\r
- public byte HiberFileType; // Ignore if earlier than Windows 10 (10.0.10240.0)\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool AoAcConnectivitySupported; // Ignore if earlier than Windows 10 (10.0.10240.0)\r
- [MarshalAs( UnmanagedType.ByValArray, SizeConst = 6 )]\r
- private readonly byte[] spare3;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool SystemBatteriesPresent;\r
- [MarshalAs( UnmanagedType.U1 )]\r
- public bool BatteriesAreShortTerm;\r
- [MarshalAs( UnmanagedType.ByValArray, SizeConst = 3 )]\r
- public BATTERY_REPORTING_SCALE[] BatteryScale;\r
- public SYSTEM_POWER_STATE AcOnLineWake;\r
- public SYSTEM_POWER_STATE SoftLidWake;\r
- public SYSTEM_POWER_STATE RtcWake;\r
- public SYSTEM_POWER_STATE MinDeviceWakeState;\r
- public SYSTEM_POWER_STATE DefaultLowLatencyWake;\r
- }\r
- //-----------------\r
- #endregion\r
-\r
- \r
- // プロパティ\r
-\r
- public static bool bアプリがIdle状態である\r
- {\r
- get\r
- {\r
- WindowMessage message;\r
- return !PeekMessage( out message, IntPtr.Zero, 0, 0, 0 );\r
- }\r
- }\r
-\r
-\r
- // キーボードの特殊機能の制御\r
-\r
- public static class Cトグルキー機能\r
- {\r
- public static void t無効化する()\r
- {\r
- if( ( stored.dwFlags & 1L ) == 0L )\r
- {\r
- CWin32.TOGGLEKEYS structure = new CWin32.TOGGLEKEYS();\r
- structure.dwFlags = stored.dwFlags;\r
- structure.cbSize = stored.cbSize;\r
- structure.dwFlags &= -5;\r
- structure.dwFlags &= -9;\r
- int cb = Marshal.SizeOf( structure );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( structure, ptr, false );\r
- CWin32.SystemParametersInfo( 0x35, (uint) cb, ptr, 0 );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
- }\r
- public static void t復元する()\r
- {\r
- int cb = Marshal.SizeOf( stored );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( stored, ptr, false );\r
- CWin32.SystemParametersInfo( 0x35, (uint) cb, ptr, 0 );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
-\r
- #region [ private ]\r
- //-----------------\r
- static Cトグルキー機能()\r
- {\r
- int cb = Marshal.SizeOf( stored );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( stored, ptr, false );\r
- CWin32.SystemParametersInfo( 0x34, (uint) cb, ptr, 0 );\r
- stored = (CWin32.TOGGLEKEYS) Marshal.PtrToStructure( ptr, typeof( CWin32.TOGGLEKEYS ) );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
-\r
- private const uint SPI_GETTOGGLEKEYS = 0x34;\r
- private const uint SPI_SETTOGGLEKEYS = 0x35;\r
- private static CWin32.TOGGLEKEYS stored = new CWin32.TOGGLEKEYS();\r
- private const uint TKF_CONFIRMHOTKEY = 8;\r
- private const uint TKF_HOTKEYACTIVE = 4;\r
- private const uint TKF_TOGGLEKEYSON = 1;\r
- //-----------------\r
- #endregion\r
- }\r
- public static class Cフィルタキー機能\r
- {\r
- public static void t無効化する()\r
- {\r
- if( ( stored.dwFlags & 1L ) == 0L )\r
- {\r
- CWin32.FILTERKEYS structure = new CWin32.FILTERKEYS();\r
- structure.dwFlags = stored.dwFlags;\r
- structure.cbSize = stored.cbSize;\r
- structure.dwFlags &= -5;\r
- structure.dwFlags &= -9;\r
- int cb = Marshal.SizeOf( structure );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( structure, ptr, false );\r
- CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
- }\r
- public static void t復元する()\r
- {\r
- int cb = Marshal.SizeOf( stored );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( stored, ptr, false );\r
- CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
-\r
- #region [ private ]\r
- //-----------------\r
- static Cフィルタキー機能()\r
- {\r
- stored.cbSize = 0;\r
- stored.dwFlags = 0;\r
- int cb = Marshal.SizeOf( stored );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( stored, ptr, false );\r
- CWin32.SystemParametersInfo( 50, (uint) cb, ptr, 0 );\r
- stored = (CWin32.FILTERKEYS) Marshal.PtrToStructure( ptr, typeof( CWin32.FILTERKEYS ) );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
- \r
- private const uint FKF_CONFIRMHOTKEY = 8;\r
- private const uint FKF_FILTERKEYSON = 1;\r
- private const uint FKF_HOTKEYACTIVE = 4;\r
- private const uint SPI_GETFILTERKEYS = 50;\r
- private const uint SPI_SETFILTERKEYS = 0x3b;\r
- private static CWin32.FILTERKEYS stored = new CWin32.FILTERKEYS();\r
- //-----------------\r
- #endregion\r
- }\r
- public static class C固定キー機能\r
- {\r
- public static void t無効化する()\r
- {\r
- if( ( stored.dwFlags & 1L ) == 0L )\r
- {\r
- CWin32.STICKYKEYS structure = new CWin32.STICKYKEYS();\r
- structure.dwFlags = stored.dwFlags;\r
- structure.cbSize = stored.cbSize;\r
- structure.dwFlags &= -5;\r
- structure.dwFlags &= -9;\r
- int cb = Marshal.SizeOf( structure );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( structure, ptr, false );\r
- CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
- }\r
- public static void t復元する()\r
- {\r
- int cb = Marshal.SizeOf( stored );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( stored, ptr, false );\r
- CWin32.SystemParametersInfo( 0x3b, (uint) cb, ptr, 0 );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
- \r
- #region [ private ]\r
- //-----------------\r
- static C固定キー機能()\r
- {\r
- stored.cbSize = 0;\r
- stored.dwFlags = 0;\r
- int cb = Marshal.SizeOf( stored );\r
- IntPtr ptr = Marshal.AllocCoTaskMem( cb );\r
- Marshal.StructureToPtr( stored, ptr, false );\r
- CWin32.SystemParametersInfo( 0x3a, (uint) cb, ptr, 0 );\r
- stored = (CWin32.STICKYKEYS) Marshal.PtrToStructure( ptr, typeof( CWin32.STICKYKEYS ) );\r
- Marshal.FreeCoTaskMem( ptr );\r
- }\r
-\r
- private const uint SKF_CONFIRMHOTKEY = 8;\r
- private const uint SKF_HOTKEYACTIVE = 4;\r
- private const uint SKF_STICKYKEYSON = 1;\r
- private const uint SPI_GETSTICKYKEYS = 0x3a;\r
- private const uint SPI_SETSTICKYKEYS = 0x3b;\r
- private static CWin32.STICKYKEYS stored = new CWin32.STICKYKEYS();\r
- //-----------------\r
- #endregion\r
- }\r
-\r
-\r
- // Win32 メッセージ処理デリゲート\r
-\r
- public delegate void MidiInProc( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 );\r
- }\r
-}\r