Функции win 32 в c# dll import

Функции win 32 в c# dll import

  public class Win32

    {

        #region Constants

 

        #region Window Styles

        /*

             * Window Styles

             */

        public const uint WS_OVERLAPPED = 0x00000000;

        public const uint WS_POPUP = 0x80000000;

        public const uint WS_CHILD = 0x40000000;

        public const uint WS_MINIMIZE = 0x20000000;

        public const uint WS_VISIBLE = 0x10000000;

        public const uint WS_DISABLED = 0x08000000;

        public const uint WS_CLIPSIBLINGS = 0x04000000;

        public const uint WS_CLIPCHILDREN = 0x02000000;

        public const uint WS_MAXIMIZE = 0x01000000;

        public const uint WS_CAPTION = 0x00C00000; /*

WS_BORDER | WS_DLGFRAME  */

        public const uint WS_BORDER = 0x00800000;

        public const uint WS_DLGFRAME = 0x00400000;

        public const uint WS_VSCROLL = 0x00200000;

        public const uint WS_HSCROLL = 0x00100000;

        public const uint WS_SYSMENU = 0x00080000;

        public const uint WS_THICKFRAME = 0x00040000;

        public const uint WS_GROUP = 0x00020000;

        public const uint WS_TABSTOP = 0x00010000;

 

        public const uint WS_MINIMIZEBOX = 0x00020000;

        public const uint WS_MAXIMIZEBOX = 0x00010000;

 

 

        public const uint WS_TILED = WS_OVERLAPPED;

        public const uint WS_ICONIC = WS_MINIMIZE;

        public const uint WS_SIZEBOX = WS_THICKFRAME;

        //public const uint WS_TILEDWINDOW      = WS_OVERLAPPEDWINDOW;

        #endregion

 

        public const int SM_REMOTESESSION        = 0x1000;

        //

        // PeekMessage() Options

        //

        public const int PM_NOREMOVE = 0x0000;

        public const int PM_REMOVE = 0x0001;

        public const int PM_NOYIELD = 0x0002;

 

        /*

         * WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes

         */

        #region WM_NCHITTEST

        public const int HTERROR = -2;

        public const int HTTRANSPARENT = -1;

        public const int HTNOWHERE = 0;

        public const int HTCLIENT = 1;

        public const int HTCAPTION = 2;

        public const int HTSYSMENU = 3;

        public const int HTGROWBOX = 4;

        public const int HTSIZE = HTGROWBOX;

        public const int HTMENU = 5;

        public const int HTHSCROLL = 6;

        public const int HTVSCROLL = 7;

        public const int HTMINBUTTON = 8;

        public const int HTMAXBUTTON = 9;

        public const int HTLEFT = 10;

        public const int HTRIGHT = 11;

        public const int HTTOP = 12;

        public const int HTTOPLEFT = 13;

        public const int HTTOPRIGHT = 14;

        public const int HTBOTTOM = 15;

        public const int HTBOTTOMLEFT = 16;

        public const int HTBOTTOMRIGHT = 17;

        public const int HTBORDER = 18;

        public const int HTREDUCE = HTMINBUTTON;

        public const int HTZOOM = HTMAXBUTTON;

        public const int HTSIZEFIRST = HTLEFT;

        public const int HTSIZELAST = HTBOTTOMRIGHT;

        public const int HTOBJECT = 19;

        public const int HTCLOSE = 20;

        public const int HTHELP = 21;

        #endregion

 

        public const int GW_HWNDFIRST = 0;

        public const int GW_HWNDLAST = 1;

        public const int GW_HWNDNEXT = 2;

        public const int GW_HWNDPREV = 3;

        public const int GW_OWNER = 4;

        public const int GW_CHILD = 5;

 

        /* Window field offsets for GetWindowLong()

                                       */

        public const int GWL_WNDPROC = (-4);

        public const int GWL_HINSTANCE = (-6);

        public const int GWL_HWNDPARENT = (-8);

        public const int GWL_STYLE = (-16);

        public const int GWL_EXSTYLE = (-20);

        public const int GWL_USERDATA = (-21);

        public const int GWL_ID = (-12);

 

        /*

         * Window Messages

         */

 

        public const int WM_NULL = 0x0000;

        public const int WM_CREATE = 0x0001;

        public const int WM_DESTROY = 0x0002;

        public const int WM_MOVE = 0x0003;

        public const int WM_SIZE = 0x0005;

 

        public const int WM_ACTIVATE = 0x0006;

        /*

         * WM_ACTIVATE state values

         */

 

        public const int WA_INACTIVE = 0;

        public const int WA_ACTIVE = 1;

        public const int WA_CLICKACTIVE = 2;

 

        public const int WM_SETFOCUS = 0x0007;

        public const int WM_KILLFOCUS = 0x0008;

        public const int WM_ENABLE = 0x000A;

        public const int WM_SETREDRAW = 0x000B;

        public const int WM_SETTEXT = 0x000C;

        public const int WM_GETTEXT = 0x000D;

        public const int WM_GETTEXTLENGTH = 0x000E;

        public const int WM_PAINT = 0x000F;

        public const int WM_CLOSE = 0x0010;

        public const int WM_QUERYENDSESSION = 0x0011;

        public const int WM_QUERYOPEN = 0x0013;

        public const int WM_ENDSESSION = 0x0016;

        public const int WM_QUIT = 0x0012;

        public const int WM_ERASEBKGND = 0x0014;

        public const int WM_SYSCOLORCHANGE = 0x0015;

        public const int WM_SHOWWINDOW = 0x0018;

        public const int WM_WININICHANGE = 0x001A;

        public const int WM_SETTINGCHANGE = WM_WININICHANGE;

 

 

        public const int WM_DEVMODECHANGE = 0x001B;

        public const int WM_ACTIVATEAPP = 0x001C;

        public const int WM_FONTCHANGE = 0x001D;

        public const int WM_TIMECHANGE = 0x001E;

        public const int WM_CANCELMODE = 0x001F;

        public const int WM_SETCURSOR = 0x0020;

        public const int WM_MOUSEACTIVATE = 0x0021;

        public const int WM_CHILDACTIVATE = 0x0022;

        public const int WM_QUEUESYNC = 0x0023;

 

        public const int WM_GETMINMAXINFO = 0x0024;

        public const int WM_PAINTICON = 0x0026;

        public const int WM_ICONERASEBKGND = 0x0027;

        public const int WM_NEXTDLGCTL = 0x0028;

        public const int WM_SPOOLERSTATUS = 0x002A;

        public const int WM_DRAWITEM = 0x002B;

        public const int WM_MEASUREITEM = 0x002C;

        public const int WM_DELETEITEM = 0x002D;

        public const int WM_VKEYTOITEM = 0x002E;

        public const int WM_CHARTOITEM = 0x002F;

        public const int WM_SETFONT = 0x0030;

        public const int WM_GETFONT = 0x0031;

        public const int WM_SETHOTKEY = 0x0032;

        public const int WM_GETHOTKEY = 0x0033;

        public const int WM_QUERYDRAGICON = 0x0037;

        public const int WM_COMPAREITEM = 0x0039;

        public const int WM_GETOBJECT = 0x003D;

        public const int WM_COMPACTING = 0x0041;

        public const int WM_COMMNOTIFY = 0x0044;  /* no longer suported */

        public const int WM_WINDOWPOSCHANGING = 0x0046;

        public const int WM_WINDOWPOSCHANGED = 0x0047;

 

        public const int WM_POWER = 0x0048;

        public const int PWR_OK = 1;

        public const int PWR_FAIL = (-1);

        public const int PWR_SUSPENDREQUEST = 1;

        public const int PWR_SUSPENDRESUME = 2;

        public const int PWR_CRITICALRESUME = 3;

 

        public const int WM_COPYDATA = 0x004A;

        public const int WM_CANCELJOURNAL = 0x004B;

 

        public const int WM_NOTIFY = 0x004E;

        public const int WM_INPUTLANGCHANGEREQUEST = 0x0050;

        public const int WM_INPUTLANGCHANGE = 0x0051;

        public const int WM_TCARD = 0x0052;

        public const int WM_HELP = 0x0053;

        public const int WM_USERCHANGED = 0x0054;

        public const int WM_NOTIFYFORMAT = 0x0055;

 

        public const int NFR_ANSI = 1;

        public const int NFR_UNICODE = 2;

        public const int NF_QUERY = 3;

        public const int NF_REQUERY = 4;

 

        public const int WM_CONTEXTMENU = 0x007B;

        public const int WM_STYLECHANGING = 0x007C;

        public const int WM_STYLECHANGED = 0x007D;

        public const int WM_DISPLAYCHANGE = 0x007E;

        public const int WM_GETICON = 0x007F;

        public const int WM_SETICON = 0x0080;

 

        public const int WM_NCCREATE = 0x0081;

        public const int WM_NCDESTROY = 0x0082;

        public const int WM_NCCALCSIZE = 0x0083;

        public const int WM_NCHITTEST = 0x0084;

        public const int WM_NCPAINT = 0x0085;

        public const int WM_NCACTIVATE = 0x0086;

        public const int WM_GETDLGCODE = 0x0087;

        public const int WM_SYNCPAINT = 0x0088;

        public const int WM_NCMOUSEMOVE = 0x00A0;

        public const int WM_NCLBUTTONDOWN = 0x00A1;

        public const int WM_NCLBUTTONUP = 0x00A2;

        public const int WM_NCLBUTTONDBLCLK = 0x00A3;

        public const int WM_NCRBUTTONDOWN = 0x00A4;

        public const int WM_NCRBUTTONUP = 0x00A5;

        public const int WM_NCRBUTTONDBLCLK = 0x00A6;

        public const int WM_NCMBUTTONDOWN = 0x00A7;

        public const int WM_NCMBUTTONUP = 0x00A8;

        public const int WM_NCMBUTTONDBLCLK = 0x00A9;

 

 

 

        public const int WM_NCXBUTTONDOWN = 0x00AB;

        public const int WM_NCXBUTTONUP = 0x00AC;

        public const int WM_NCXBUTTONDBLCLK = 0x00AD;

 

 

        public const int WM_INPUT = 0x00FF;

 

        public const int WM_KEYFIRST = 0x0100;

        public const int WM_KEYDOWN = 0x0100;

        public const int WM_KEYUP = 0x0101;

        public const int WM_CHAR = 0x0102;

        public const int WM_DEADCHAR = 0x0103;

        public const int WM_SYSKEYDOWN = 0x0104;

        public const int WM_SYSKEYUP = 0x0105;

        public const int WM_SYSCHAR = 0x0106;

        public const int WM_SYSDEADCHAR = 0x0107;

        public const int WM_UNICHAR = 0x0109;

        public const int WM_KEYLAST = 0x0109;

        public const int UNICODE_NOCHAR = 0xFFFF;

        public const int WM_IME_STARTCOMPOSITION = 0x010D;

        public const int WM_IME_ENDCOMPOSITION = 0x010E;

        public const int WM_IME_COMPOSITION = 0x010F;

        public const int WM_IME_KEYLAST = 0x010F;

 

        public const int WM_INITDIALOG = 0x0110;

        public const int WM_COMMAND = 0x0111;

        public const int WM_SYSCOMMAND = 0x0112;

        public const int WM_TIMER = 0x0113;

        public const int WM_HSCROLL = 0x0114;

        public const int WM_VSCROLL = 0x0115;

        public const int WM_INITMENU = 0x0116;

        public const int WM_INITMENUPOPUP = 0x0117;

        public const int WM_MENUSELECT = 0x011F;

        public const int WM_MENUCHAR = 0x0120;

        public const int WM_ENTERIDLE = 0x0121;

        public const int WM_MENURBUTTONUP = 0x0122;

        public const int WM_MENUDRAG = 0x0123;

        public const int WM_MENUGETOBJECT = 0x0124;

        public const int WM_UNINITMENUPOPUP = 0x0125;

        public const int WM_MENUCOMMAND = 0x0126;

 

        public const int WM_CHANGEUISTATE = 0x0127;

        public const int WM_UPDATEUISTATE = 0x0128;

        public const int WM_QUERYUISTATE = 0x0129;

 

        /*

         * LOWORD(wParam) values in WM_*UISTATE*

         */

        public const int UIS_SET = 1;

        public const int UIS_CLEAR = 2;

        public const int UIS_INITIALIZE = 3;

 

        /*

         * HIWORD(wParam) values in WM_*UISTATE*

         */

        public const int UISF_HIDEFOCUS = 0x1;

        public const int UISF_HIDEACCEL = 0x2;

        public const int UISF_ACTIVE = 0x4;

 

 

        public const int WM_CTLCOLORMSGBOX = 0x0132;

        public const int WM_CTLCOLOREDIT = 0x0133;

        public const int WM_CTLCOLORLISTBOX = 0x0134;

        public const int WM_CTLCOLORBTN = 0x0135;

        public const int WM_CTLCOLORDLG = 0x0136;

        public const int WM_CTLCOLORSCROLLBAR = 0x0137;

        public const int WM_CTLCOLORSTATIC = 0x0138;

        public const int MN_GETHMENU = 0x01E1;

 

        public const int WM_MOUSEFIRST = 0x0200;

        public const int WM_MOUSEMOVE = 0x0200;

        public const int WM_LBUTTONDOWN = 0x0201;

        public const int WM_LBUTTONUP = 0x0202;

        public const int WM_LBUTTONDBLCLK = 0x0203;

        public const int WM_RBUTTONDOWN = 0x0204;

        public const int WM_RBUTTONUP = 0x0205;

        public const int WM_RBUTTONDBLCLK = 0x0206;

        public const int WM_MBUTTONDOWN = 0x0207;

        public const int WM_MBUTTONUP = 0x0208;

        public const int WM_MBUTTONDBLCLK = 0x0209;

        public const int WM_MOUSEWHEEL = 0x020A;

        public const int WM_XBUTTONDOWN = 0x020B;

        public const int WM_XBUTTONUP = 0x020C;

        public const int WM_XBUTTONDBLCLK = 0x020D;

        public const int WM_MOUSELAST = 0x020D;

 

 

        /* Value for rolling one detent */

        public const int WHEEL_DELTA = 120;

 

 

        /* XButton values are WORD flags */

        public const int XBUTTON1 = 0x0001;

        public const int XBUTTON2 = 0x0002;

        /* Were there to be an XBUTTON3, its value would be 0x0004 */

 

        public const int WM_PARENTNOTIFY = 0x0210;

        public const int WM_ENTERMENULOOP = 0x0211;

        public const int WM_EXITMENULOOP = 0x0212;

 

        public const int WM_NEXTMENU = 0x0213;

        public const int WM_SIZING = 0x0214;

        public const int WM_CAPTURECHANGED = 0x0215;

        public const int WM_MOVING = 0x0216;

 

 

        public const int WM_POWERBROADCAST = 0x0218;

 

        public const int PBT_APMQUERYSUSPEND = 0x0000;

        public const int PBT_APMQUERYSTANDBY = 0x0001;

 

        public const int PBT_APMQUERYSUSPENDFAILED = 0x0002;

        public const int PBT_APMQUERYSTANDBYFAILED = 0x0003;

 

        public const int PBT_APMSUSPEND = 0x0004;

        public const int PBT_APMSTANDBY = 0x0005;

 

        public const int PBT_APMRESUMECRITICAL = 0x0006;

        public const int PBT_APMRESUMESUSPEND = 0x0007;

        public const int PBT_APMRESUMESTANDBY = 0x0008;

 

        public const int PBTF_APMRESUMEFROMFAILURE = 0x00000001;

 

        public const int PBT_APMBATTERYLOW = 0x0009;

        public const int PBT_APMPOWERSTATUSCHANGE = 0x000A;

 

        public const int PBT_APMOEMEVENT = 0x000B;

        public const int PBT_APMRESUMEAUTOMATIC = 0x0012;

 

        public const int WM_DEVICECHANGE = 0x0219;

 

        public const int WM_MDICREATE = 0x0220;

        public const int WM_MDIDESTROY = 0x0221;

        public const int WM_MDIACTIVATE = 0x0222;

        public const int WM_MDIRESTORE = 0x0223;

        public const int WM_MDINEXT = 0x0224;

        public const int WM_MDIMAXIMIZE = 0x0225;

        public const int WM_MDITILE = 0x0226;

        public const int WM_MDICASCADE = 0x0227;

        public const int WM_MDIICONARRANGE = 0x0228;

        public const int WM_MDIGETACTIVE = 0x0229;

 

 

        public const int WM_MDISETMENU = 0x0230;

        public const int WM_ENTERSIZEMOVE = 0x0231;

        public const int WM_EXITSIZEMOVE = 0x0232;

        public const int WM_DROPFILES = 0x0233;

        public const int WM_MDIREFRESHMENU = 0x0234;

 

 

        public const int WM_IME_SETCONTEXT = 0x0281;

        public const int WM_IME_NOTIFY = 0x0282;

        public const int WM_IME_CONTROL = 0x0283;

        public const int WM_IME_COMPOSITIONFULL = 0x0284;

        public const int WM_IME_SELECT = 0x0285;

        public const int WM_IME_CHAR = 0x0286;

        public const int WM_IME_REQUEST = 0x0288;

        public const int WM_IME_KEYDOWN = 0x0290;

        public const int WM_IME_KEYUP = 0x0291;

        public const int WM_MOUSEHOVER = 0x02A1;

        public const int WM_MOUSELEAVE = 0x02A3;

        public const int WM_NCMOUSEHOVER = 0x02A0;

        public const int WM_NCMOUSELEAVE = 0x02A2;

        public const int WM_WTSSESSION_CHANGE = 0x02B1;

        public const int WM_TABLET_FIRST = 0x02c0;

        public const int WM_TABLET_LAST = 0x02df;

        public const int WM_CUT = 0x0300;

        public const int WM_COPY = 0x0301;

        public const int WM_PASTE = 0x0302;

        public const int WM_CLEAR = 0x0303;

        public const int WM_UNDO = 0x0304;

        public const int WM_RENDERFORMAT = 0x0305;

        public const int WM_RENDERALLFORMATS = 0x0306;

        public const int WM_DESTROYCLIPBOARD = 0x0307;

        public const int WM_DRAWCLIPBOARD = 0x0308;

        public const int WM_PAINTCLIPBOARD = 0x0309;

        public const int WM_VSCROLLCLIPBOARD = 0x030A;

        public const int WM_SIZECLIPBOARD = 0x030B;

        public const int WM_ASKCBFORMATNAME = 0x030C;

        public const int WM_CHANGECBCHAIN = 0x030D;

 

        public const int WM_HSCROLLCLIPBOARD = 0x030E;

        public const int WM_QUERYNEWPALETTE = 0x030F;

        public const int WM_PALETTEISCHANGING = 0x0310;

        public const int WM_PALETTECHANGED = 0x0311;

        public const int WM_HOTKEY = 0x0312;

        public const int WM_PRINT = 0x0317;

        public const int WM_PRINTCLIENT = 0x0318;

        public const int WM_APPCOMMAND = 0x0319;

        public const int WM_THEMECHANGED = 0x031A;

        public const int WM_HANDHELDFIRST = 0x0358;

        public const int WM_HANDHELDLAST = 0x035F;

        public const int WM_AFXFIRST = 0x0360;

        public const int WM_AFXLAST = 0x037F;

        public const int WM_PENWINFIRST = 0x0380;

        public const int WM_PENWINLAST = 0x038F;

        public const int WM_APP = 0x8000;

 

 

        #endregion

 

        #region DllImport - User32

 

        #region Virtual Keys, Standard Set

        /*

             * Virtual Keys, Standard Set

             */

        public const int VK_LBUTTON = 0x01;

        public const int VK_RBUTTON = 0x02;

        public const int VK_CANCEL = 0x03;

        public const int VK_MBUTTON = 0x04;    /* NOT

contiguous with L & RBUTTON */

 

        public const int VK_XBUTTON1 = 0x05; /* NOT contiguous

with L & RBUTTON */

        public const int VK_XBUTTON2 = 0x06; /* NOT contiguous

with L & RBUTTON */

 

        /*

         * 0x07 : unassigned

         */

 

        public const int VK_BACK = 0x08;

        public const int VK_TAB = 0x09;

 

        /*

         * 0x0A - 0x0B : reserved

         */

 

        public const int VK_CLEAR = 0x0C;

        public const int VK_RETURN = 0x0D;

 

        public const int VK_SHIFT = 0x10;

        public const int VK_CONTROL = 0x11;

        public const int VK_MENU = 0x12;

        public const int VK_PAUSE = 0x13;

        public const int VK_CAPITAL = 0x14;

 

        public const int VK_KANA = 0x15;

        public const int VK_HANGEUL = 0x15; /* old name -

should be here for compatibility */

        public const int VK_HANGUL = 0x15;

        public const int VK_JUNJA = 0x17;

        public const int VK_FINAL = 0x18;

        public const int VK_HANJA = 0x19;

        public const int VK_KANJI = 0x19;

 

        public const int VK_ESCAPE = 0x1B;

 

        public const int VK_CONVERT = 0x1C;

        public const int VK_NONCONVERT = 0x1D;

        public const int VK_ACCEPT = 0x1E;

        public const int VK_MODECHANGE = 0x1F;

 

        public const int VK_SPACE = 0x20;

        public const int VK_PRIOR = 0x21;

        public const int VK_NEXT = 0x22;

        public const int VK_END = 0x23;

        public const int VK_HOME = 0x24;

        public const int VK_LEFT = 0x25;

        public const int VK_UP = 0x26;

        public const int VK_RIGHT = 0x27;

        public const int VK_DOWN = 0x28;

        public const int VK_SELECT = 0x29;

        public const int VK_PRINT = 0x2A;

        public const int VK_EXECUTE = 0x2B;

        public const int VK_SNAPSHOT = 0x2C;

        public const int VK_INSERT = 0x2D;

        public const int VK_DELETE = 0x2E;

        public const int VK_HELP = 0x2F;

 

        /*

         * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)

         * 0x40 : unassigned

         * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)

         */

 

        public const int VK_LWIN = 0x5B;

        public const int VK_RWIN = 0x5C;

        public const int VK_APPS = 0x5D;

 

        /*

         * 0x5E : reserved

         */

 

        public const int VK_SLEEP = 0x5F;

 

        public const int VK_NUMPAD0 = 0x60;

        public const int VK_NUMPAD1 = 0x61;

        public const int VK_NUMPAD2 = 0x62;

        public const int VK_NUMPAD3 = 0x63;

        public const int VK_NUMPAD4 = 0x64;

        public const int VK_NUMPAD5 = 0x65;

        public const int VK_NUMPAD6 = 0x66;

        public const int VK_NUMPAD7 = 0x67;

        public const int VK_NUMPAD8 = 0x68;

        public const int VK_NUMPAD9 = 0x69;

        public const int VK_MULTIPLY = 0x6A;

        public const int VK_ADD = 0x6B;

        public const int VK_SEPARATOR = 0x6C;

        public const int VK_SUBTRACT = 0x6D;

        public const int VK_DECIMAL = 0x6E;

        public const int VK_DIVIDE = 0x6F;

        public const int VK_F1 = 0x70;

        public const int VK_F2 = 0x71;

        public const int VK_F3 = 0x72;

        public const int VK_F4 = 0x73;

        public const int VK_F5 = 0x74;

        public const int VK_F6 = 0x75;

        public const int VK_F7 = 0x76;

        public const int VK_F8 = 0x77;

        public const int VK_F9 = 0x78;

        public const int VK_F10 = 0x79;

        public const int VK_F11 = 0x7A;

        public const int VK_F12 = 0x7B;

        public const int VK_F13 = 0x7C;

        public const int VK_F14 = 0x7D;

        public const int VK_F15 = 0x7E;

        public const int VK_F16 = 0x7F;

        public const int VK_F17 = 0x80;

        public const int VK_F18 = 0x81;

        public const int VK_F19 = 0x82;

        public const int VK_F20 = 0x83;

        public const int VK_F21 = 0x84;

        public const int VK_F22 = 0x85;

        public const int VK_F23 = 0x86;

        public const int VK_F24 = 0x87;

 

        /*

         * 0x88 - 0x8F : unassigned

         */

 

        public const int VK_NUMLOCK = 0x90;

        public const int VK_SCROLL = 0x91;

 

        /*

         * NEC PC-9800 kbd definitions

         */

        public const int VK_OEM_NEC_EQUAL = 0x92; // '=' key on numpad

 

        /*

         * Fujitsu/OASYS kbd definitions

         */

        public const int VK_OEM_FJ_JISHO = 0x92; // 'Dictionary' key

        public const int VK_OEM_FJ_MASSHOU = 0x93; // 'Unregister word' key

        public const int VK_OEM_FJ_TOUROKU = 0x94; // 'Register word' key

        public const int VK_OEM_FJ_LOYA = 0x95; // 'Left OYAYUBI' key

        public const int VK_OEM_FJ_ROYA = 0x96; // 'Right OYAYUBI' key

 

        /*

         * 0x97 - 0x9F : unassigned

         */

 

        /*

         * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.

         * Used only as parameters to GetAsyncKeyState() and GetKeyState().

         * No other API or message will distinguish left

and right keys in this way.

         */

        public const int VK_LSHIFT = 0xA0;

        public const int VK_RSHIFT = 0xA1;

        public const int VK_LCONTROL = 0xA2;

        public const int VK_RCONTROL = 0xA3;

        public const int VK_LMENU = 0xA4;

        public const int VK_RMENU = 0xA5;

        #endregion

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int GetSystemMetrics(int nIndex);

       

        public static bool IsRemoteSession()

        {

            return GetSystemMetrics(SM_REMOTESESSION)==0?false:true;

        }

 

 

        /*

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint LockWindowUpdate(IntPtr hWnd);

 

        public static uint LockWindowUpdate(Control ctrl)

        {

            if (ctrl == null)

            {

                return LockWindowUpdate(IntPtr.Zero);

            }

            else

                return LockWindowUpdate(ctrl.Handle);

        }

        */

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint PeekMessage(ref MSG lpMsg,

                    IntPtr hWnd,

                    uint wMsgFilterMin,

                    uint wMsgFilterMax,

                    uint wRemoveMsg

                );

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr DispatchMessage(ref MSG lpmsg);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern Int16 GetAsyncKeyState(

            int vKey);

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int SetScrollPos(

            IntPtr hWnd,

            int nBar,

            int nPos,

            int bRedraw);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int GetScrollPos(

            IntPtr hWnd,

            int nBar);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int SetScrollRange(

            IntPtr hWnd,

            int nBar,

            int nMinPos,

            int nMaxPos,

            int bRedraw);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int GetScrollRange(

            IntPtr hWnd,

            int nBar,

            ref int lpMinPos,

            ref int lpMaxPos);

 

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint SetWindowLong(

            IntPtr hWnd,

            int nIndex,

            uint dwNewLong

            );

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr FindWindow(

            string lpClassName,

            string lpWindowName

            );

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr FindWindowEx(

            IntPtr hwndParent,

            IntPtr hwndChildAfter,

            string lpszClass,

            string lpszWindow

            );

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint ShowWindow(

            IntPtr hWnd,

            int nCmdShow

            );

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int PostMessage(

            IntPtr hWnd,

            uint Msg,

            int wParam,

            int lParam

            );

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int SendMessage(

            IntPtr hWnd,

            uint Msg,

            int wParam,

            int lParam

            );

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint GetWindowLong(

            IntPtr hWnd,

            int nIndex);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint SetForegroundWindow(

            IntPtr hWnd);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr SetActiveWindow(

            IntPtr hWnd);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr GetParent(

            IntPtr hWnd);

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr GetActiveWindow();

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr GetForegroundWindow();

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int BringWindowToTop(

            IntPtr hWnd);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern void SwitchToThisWindow(

            IntPtr hWnd, int fl);

 

 

 

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr SetFocus(

            IntPtr hWnd);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern uint SetWindowText(

            IntPtr hWnd,

            string String);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr GetDC(IntPtr handle);

 

        [DllImport("User32", CharSet = CharSet.Auto)]

        public static extern IntPtr GetWindowDC(IntPtr handle);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr ReleaseDC(IntPtr handle, IntPtr hDC);

 

        [DllImport("Gdi32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr CreateCompatibleDC(IntPtr hdc);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int GetClassName(IntPtr hwnd,

char[] className, int maxCount);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern int GetWindowText(IntPtr hwnd,

char[] windowText, int maxCount);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern IntPtr GetWindow(IntPtr hwnd, int uCmd);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern bool IsWindow(IntPtr hwnd);

 

        [DllImport("User32.dll", CharSet = CharSet.Auto)]

        public static extern bool IsWindowVisible(IntPtr hwnd);

 

        [DllImport("user32", CharSet = CharSet.Auto)]

        public static extern int GetClientRect(IntPtr hwnd,

ref RECT lpRect);

 

        [DllImport("user32", CharSet = CharSet.Auto)]

        public static extern int GetClientRect(IntPtr hwnd,

[In, Out] ref Rectangle rect);

 

        [DllImport("user32", CharSet = CharSet.Auto)]

        public static extern bool MoveWindow(IntPtr hwnd, int X,

int Y, int nWidth, int nHeight, bool bRepaint);

 

        [DllImport("user32", CharSet = CharSet.Auto)]

        public static extern bool UpdateWindow(IntPtr hwnd);

 

        [DllImport("user32", CharSet = CharSet.Auto)]

        public static extern bool InvalidateRect(IntPtr hwnd,

ref Rectangle rect, bool bErase);

 

        [DllImport("user32", CharSet = CharSet.Auto)]

        public static extern bool ValidateRect(IntPtr hwnd,

ref Rectangle rect);

 

        [DllImport("user32.dll", CharSet = CharSet.Auto)]

        internal static extern bool GetWindowRect(IntPtr hWnd,

[In, Out] ref Rectangle rect);

 

 

        [DllImport("User32.dll")]

        public static extern int GetUpdateRect(IntPtr hwnd,

ref RECT rect, bool erase);

 

        [DllImport("User32.dll", SetLastError = true)]

        public static extern bool GetWindowRect(IntPtr handle,

ref RECT rect);

 

        [DllImport("User32.dll")]

        public static extern IntPtr BeginPaint(IntPtr hWnd,

ref PAINTSTRUCT paintStruct);

 

        [DllImport("User32.dll")]

        public static extern bool EndPaint(IntPtr hWnd,

ref PAINTSTRUCT paintStruct);

 

 

        #endregion

 

        #region DllImport - Kernel32

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern uint GetCurrentProcessId();

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern uint GetTickCount();

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern void ExitProcess(uint uExitCode);

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern uint IsDebuggerPresent();

 

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern void SetLastError(uint value);

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern uint GetLastError();

 

        [DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

        public static extern uint WinExec(string lpCmdLine,

uint uCmdShow);

 

        #endregion

 

        #region DllImport - Gdi32

 

        public const int PFD_DOUBLEBUFFER = 0x00000001;

        public const int PFD_STEREO = 0x00000002;

        public const int PFD_DRAW_TO_WINDOW = 0x00000004;

        public const int PFD_DRAW_TO_BITMAP = 0x00000008;

        public const int PFD_SUPPORT_GDI = 0x00000010;

        public const int PFD_SUPPORT_OPENGL = 0x00000020;

        public const int PFD_GENERIC_FORMAT = 0x00000040;

        public const int PFD_NEED_PALETTE = 0x00000080;

        public const int PFD_NEED_SYSTEM_PALETTE = 0x00000100;

        public const int PFD_SWAP_EXCHANGE = 0x00000200;

        public const int PFD_SWAP_COPY = 0x00000400;

        public const int PFD_SWAP_LAYER_BUFFERS = 0x00000800;

        public const int PFD_GENERIC_ACCELERATED = 0x00001000;

        public const int PFD_SUPPORT_DIRECTDRAW = 0x00002000;

 

        public const int PFD_TYPE_RGBA = 0;

        public const int PFD_TYPE_COLORINDEX = 1;

 

        public const int PFD_MAIN_PLANE = 0;

        public const int PFD_OVERLAY_PLANE = 1;

        public const int PFD_UNDERLAY_PLANE = (-1);

 

 

        /* Pixel format descriptor */

        [StructLayout(LayoutKind.Sequential)]

        public struct PIXELFORMATDESCRIPTOR

        {

            public UInt16 nSize;

            public UInt16 nVersion;

            public UInt32 dwFlags;

            public byte iPixelType;

            public byte cColorBits;

            public byte cRedBits;

            public byte cRedShift;

            public byte cGreenBits;

            public byte cGreenShift;

            public byte cBlueBits;

            public byte cBlueShift;

            public byte cAlphaBits;

            public byte cAlphaShift;

            public byte cAccumBits;

            public byte cAccumRedBits;

            public byte cAccumGreenBits;

            public byte cAccumBlueBits;

            public byte cAccumAlphaBits;

            public byte cDepthBits;

            public byte cStencilBits;

            public byte cAuxBuffers;

            public byte iLayerType;

            public byte bReserved;

            public UInt32 dwLayerMask;

            public UInt32 dwVisibleMask;

            public UInt32 dwDamageMask;

 

            //

            // PIXELFORMATDESCRIPTOR

            //

            public PIXELFORMATDESCRIPTOR(

                //UInt16  nSize,

                UInt16 nVersion,

                UInt32 dwFlags,

                byte iPixelType,

                byte cColorBits,

                byte cRedBits,

                byte cRedShift,

                byte cGreenBits,

                byte cGreenShift,

                byte cBlueBits,

                byte cBlueShift,

                byte cAlphaBits,

                byte cAlphaShift,

                byte cAccumBits,

                byte cAccumRedBits,

                byte cAccumGreenBits,

                byte cAccumBlueBits,

                byte cAccumAlphaBits,

                byte cDepthBits,

                byte cStencilBits,

                byte cAuxBuffers,

                byte iLayerType,

                byte bReserved,//26

                UInt32 dwLayerMask,

                UInt32 dwVisibleMask,

                UInt32 dwDamageMask

                )

            {

                this.nSize = (ushort)38;

// sizeof(PIXELFORMATDESCRIPTOR);//nSize;

                this.nVersion = nVersion;

                this.dwFlags = dwFlags;

                this.iPixelType = iPixelType;

                this.cColorBits = cColorBits;

                this.cRedBits = cRedBits;

                this.cRedShift = cRedShift;

                this.cGreenBits = cGreenBits;

                this.cGreenShift = cGreenShift;

                this.cBlueBits = cBlueBits;

                this.cBlueShift = cBlueShift;

                this.cAlphaBits = cAlphaBits;

                this.cAlphaShift = cAlphaShift;

                this.cAccumBits = cAccumBits;

                this.cAccumRedBits = cAccumRedBits;

                this.cAccumGreenBits = cAccumGreenBits;

                this.cAccumBlueBits = cAccumBlueBits;

                this.cAccumAlphaBits = cAccumAlphaBits;

                this.cDepthBits = cDepthBits;

                this.cStencilBits = cStencilBits;

                this.cAuxBuffers = cAuxBuffers;

                this.iLayerType = iLayerType;

                this.bReserved = bReserved;

                this.dwLayerMask = dwLayerMask;

                this.dwVisibleMask = dwVisibleMask;

                this.dwDamageMask = dwDamageMask;

            }

        };

 

 

 

        [DllImport("gdi32.dll", CharSet = CharSet.Auto)]

        internal static extern uint SetPixelFormat(

            IntPtr hdc,

            int iPixelFormat,

            ref PIXELFORMATDESCRIPTOR ppfd);

 

        [DllImport("gdi32.dll", CharSet = CharSet.Auto)]

        internal static extern int ChoosePixelFormat(

            IntPtr hdc,

            ref PIXELFORMATDESCRIPTOR ppfd);

 

        #endregion

 

        #region Structs

        [StructLayout(LayoutKind.Sequential)]

        public struct MSG

        {     // msg 

            public IntPtr hwnd;

            public uint message;

            public uint wParam;

            public uint lParam;

            public uint time;

            public POINT pt;

        }

 

        [StructLayout(LayoutKind.Sequential, Pack = 1)]

        public struct POINT

        {

            public int X;

            public int Y;

        }

 

        [StructLayout(LayoutKind.Sequential, Pack = 1)]

        public struct RECT

        {

            public int Left;

            public int Top;

            public int Right;

            public int Bottom;

        }

 

        [StructLayout(LayoutKind.Sequential)]

        public struct WINDOWPOS

        {

            public IntPtr hwnd;

            public IntPtr hwndAfter;

            public int x;

            public int y;

            public int cx;

            public int cy;

            public uint flags;

        }

 

        [StructLayout(LayoutKind.Sequential)]

        public struct NCCALCSIZE_PARAMS

        {

            public RECT rgc;

            public WINDOWPOS wndpos;

        }

 

        [StructLayout(LayoutKind.Sequential)]

        public struct PAINTSTRUCT

        {

            public IntPtr hdc;

            public int fErase;

            public RECT rcPaint;

            public int fRestore;

            public int fIncUpdate;

            public int Reserved1;

            public int Reserved2;

            public int Reserved3;

            public int Reserved4;

            public int Reserved5;

            public int Reserved6;

            public int Reserved7;

            public int Reserved8;

        }

        #endregion

 

        #region DllImport - Mpr.dll (Net)

 

        /// <summary>

        /// The NETRESOURCE structure contains

        /// information about a network resource

        /// </summary>

        [StructLayout(LayoutKind.Sequential)]

        public struct NETRESOURCE_W

        {

            public uint dwScope;

            public uint dwType;

            public uint dwDisplayType;

            public uint dwUsage;

 

            [MarshalAs(UnmanagedType.LPWStr)]

            public string lpLocalName;

 

            [MarshalAs(UnmanagedType.LPWStr)]

            public string lpRemoteName;

 

            [MarshalAs(UnmanagedType.LPWStr)]

            public string lpComment;

 

            [MarshalAs(UnmanagedType.LPWStr)]

            public string lpProvider;

        }

 

        const uint RESOURCETYPE_ANY = 0x00000000;

        const uint RESOURCETYPE_DISK = 0x00000001;

        const uint RESOURCETYPE_PRINT = 0x00000002;

 

 

        /// <summary>

        /// The WNetAddConnection2 function makes a connection to a

        /// network resource. The function can redirect a

        /// local device to the network resource.

        /// </summary>

        /// <param name="lpNetResource"></param>

        /// <param name="lpPassword"></param>

        /// <param name="lpUsername"></param>

        /// <param name="dwFlags"></param>

        /// <returns></returns>

        [DllImport("Mpr.dll", CharSet = CharSet.Unicode)]

        internal static extern uint WNetAddConnection2W(

            ref NETRESOURCE_W lpNetResource,

            string lpPassword,

            string lpUsername,

            uint dwFlags

            );

 

        /// <summary>

        /// The WNetCancelConnection2 function

        /// cancels an existing network connection.

        /// You can also call the function

        /// to remove remembered network

        /// connections that are not currently connected.

        /// </summary>

        /// <param name="lpName"></param>

        /// <param name="dwFlags"></param>

        /// <param name="fForce"></param>

        /// <returns></returns>

        [DllImport("Mpr.dll", CharSet = CharSet.Unicode)]

        internal static extern uint WNetCancelConnection2W(

            string lpName,

            uint dwFlags,

            uint fForce

            );

 

        /// <summary>

        /// Открыть подключение

        /// </summary>

        /// <param name="path"></param>

        /// <param name="user_name"></param>

        /// <param name="password"></param>

        /// <returns></returns>

        /// <exception cref=""></exception>

        public static bool OpenRemoteShare(string path,

string user_name, string password)

        {

            if (path == null || path.Length == 0)

                return false;

 

            NETRESOURCE_W NetRsrc = new NETRESOURCE_W();

 

            NetRsrc.dwDisplayType = 0;

            NetRsrc.dwScope = 0;

            NetRsrc.dwUsage = 0;

 

            NetRsrc.lpLocalName = null;

            NetRsrc.dwType = RESOURCETYPE_DISK;

            NetRsrc.lpRemoteName = path;

            NetRsrc.lpProvider = null;

 

            uint dwNetResult = WNetAddConnection2W(ref NetRsrc,

password, user_name, 0);

            if (dwNetResult != 0)

            {

                throw new Exception(

new Win32Exception((int)dwNetResult).Message);

            }

            return true;

        }

 

        /// <summary>

        /// Закрыть подключение

        /// </summary>

        /// <param name="path"></param>

        /// <returns></returns>

        public static bool CloseRemoteShare(string path)

        {

            try

            {

                if (WNetCancelConnection2W(path, 0, 1) != 0)

                    return false;

 

                return true;

            }

            catch

            {

                return false;

            }

        }

        #endregion

 

 

    }


 

 

 
11.12.2008

Отзывы и комментарии

 


 
Тема
Ваше имя
Почтовый адрес
Текст сообщения
Ключ защиты:
Защита от спама
 
 
 
 
10.12  .NET Reactor
15.11  n
15.11  C# ClickOnce
 
11.10  GAC и ngen
10.10  SqlTypes