c# – Questions about SendMessage and PostMessage

Question:

I started to study the SendMessage and PostMessage methods of User32.dll and some questions came to me. I'll put the code that I tested below and then the questions, if anyone can help me.

            [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
            public static extern IntPtr FindWindow(string lpClassName,
                                                                     string lpWindowName);

            [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
            public extern static int SendMessage(IntPtr hwnd, uint msg, uint wParam, uint lParam);
            [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
            public extern static int PostMessage(IntPtr hwnd, uint msg, uint wParam, uint lParam);

        void FechaNotepad()
            {
                IntPtr handle = FindWindow("Notepad", "Sem título - Bloco de Notas");

                const int WM_QUIT = 0x0012;
                const int WM_CLOSE = 0x0010;
                const int WM_KEYDOWN = 0x100;
                const int WM_KEYUP = 0x101;
                const int WM_COMMAND = 0x111;
                const int WM_LBUTTONDOWN = 0x201;
                const int WM_LBUTTONUP = 0x202;
                const int WM_LBUTTONDBLCLK = 0x203;
                const int WM_RBUTTONDOWN = 0x204;
                const int WM_RBUTTONUP = 0x205;
                const int WM_RBUTTONDBLCLK = 0x206;

                SendMessage(handle, WM_CLOSE, 0, 0);
                SendMessage(handle, WM_QUIT, 0, 0);
                PostMessage(handle, WM_CLOSE, 0, 0);
                PostMessage(handle, WM_QUIT, 0, 0);
            }

Doubts

In order for me to actually execute the commands in the found process, do I have to execute a SendMessage() and then a PostMessage() ? Doesn't it work just by giving a PostMessage() ?

Where do I find addresses of messages that can be sent, such as sending the message to press the F1 key on the keyboard?

Answer:

Yes, it only works with PostMessage(), however you must analyze its need, and for that you can check the difference between them. The SendMessage function is synchronous, and the PostMessage function is asynchronous.

The address of the messages (constant) I'm listing below

     // Button message
     const int BM_GETCHECK = 0x00F0;
     const int BM_GETSTATE = 0x00F2;
     const int BM_SETSTATE = 0x00F3;
    // const int BM_CLICK = 0xF0F5;
     const int BM_CLICK = 0x00F5;

    // Combobox
     const int CB_GETCURSEL = 0x0147;
     const int CB_GETLBTEXT = 0x0148;
     const int CB_GETLBTEXTLEN = 0x0149;
     const int CB_SHOWDROPDOWN = 0x014F;
     const int CB_GETDROPPEDSTATE = 0x0157;

    // Date/Time picker
     const int DTM_GETSYSTEMTIME = 0x1001;
     const int DTM_SETSYSTEMTIME = 0x1002;
     const int DTM_GETMONTHCAL = 0x1008;

    // Editbox messages
     const int EM_GETSEL = 0x00B0;
     const int EM_SETSEL = 0x00B1;
     const int EM_GETRECT = 0x00B2;
     const int EM_LINESCROLL = 0x00B6;
     const int EM_GETLINECOUNT = 0x00BA;
     const int EM_LINEINDEX = 0x00BB;
     const int EM_LINEFROMCHAR = 0x00C9;
     const int EM_GETFIRSTVISIBLELINE = 0x00CE;
     const int EM_GETLIMITTEXT = 0x00D5;
     const int EM_POSFROMCHAR = 0x00D6;
     const int EM_CHARFROMPOS = 0x00D7;

    // SysHeader
     const int HDM_FIRST = 0x1200;
     const int HDM_GETITEMCOUNT = HDM_FIRST + 0;
     const int HDM_HITTEST = HDM_FIRST + 6;
     const int HDM_GETITEMRECT = HDM_FIRST + 7;
     const int HDM_GETITEMW = HDM_FIRST + 11;
     const int HDM_ORDERTOINDEX = HDM_FIRST + 15;
     const int HDM_GETITEMDROPDOWNRECT = HDM_FIRST + 25;
     const int HDM_GETFOCUSEDITEM = HDM_FIRST + 27;

    // Listbox messages
     const int LB_ERR = -1;
     const int LB_SETSEL = 0x0185;
     const int LB_SETCURSEL = 0x0186;
     const int LB_GETSEL = 0x0187;
     const int LB_GETCURSEL = 0x0188;
     const int LB_GETTEXT = 0x0189;
     const int LB_GETTEXTLEN = 0x018A;
     const int LB_GETCOUNT = 0x018B;
     const int LB_GETSELCOUNT = 0x0190;
     const int LB_SETTOPINDEX = 0x0197;
     const int LB_GETITEMRECT = 0x0198;
     const int LB_GETITEMDATA = 0x0199;
     const int LB_SETCARETINDEX = 0x019E;
     const int LB_GETCARETINDEX = 0x019F;
     const int LB_ITEMFROMPOINT = 0x01A9;

    // Listbox notification message
     const int LBN_SELCHANGE = 1;

    // List-view messages
     const int LVM_FIRST = 0x1000;
     const int LVM_GETITEMCOUNT = LVM_FIRST + 4;
     const int LVM_GETNEXTITEM = LVM_FIRST + 12;
     const int LVM_GETITEMRECT = LVM_FIRST + 14;
     const int LVM_GETITEMPOSITION = LVM_FIRST + 16;
     const int LVM_HITTEST = (LVM_FIRST + 18);
     const int LVM_ENSUREVISIBLE = LVM_FIRST + 19;
     const int LVM_SCROLL = LVM_FIRST + 20;
     const int LVM_GETHEADER = LVM_FIRST + 31;
     const int LVM_GETITEMSTATE = LVM_FIRST + 44;
     const int LVM_SETITEMSTATE = LVM_FIRST + 43;
     const int LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55;
     const int LVM_GETSUBITEMRECT = LVM_FIRST + 56;
     const int LVM_SUBITEMHITTEST = LVM_FIRST + 57;
     const int LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64;
     const int LVM_GETITEMW = LVM_FIRST + 75;
     const int LVM_GETTOOLTIPS = LVM_FIRST + 78;
     const int LVM_GETFOCUSEDGROUP = LVM_FIRST + 93;
     const int LVM_GETGROUPRECT = LVM_FIRST + 98; 
     const int LVM_EDITLABEL = LVM_FIRST + 118;
     const int LVM_GETVIEW = LVM_FIRST + 143;
     const int LVM_SETVIEW = LVM_FIRST + 142;
     const int LVM_SETGROUPINFO = LVM_FIRST + 147;
     const int LVM_GETGROUPINFO = LVM_FIRST + 149;
     const int LVM_GETGROUPINFOBYINDEX = LVM_FIRST + 153;
     const int LVM_GETGROUPMETRICS = LVM_FIRST + 156;
     const int LVM_HASGROUP = LVM_FIRST + 161;
     const int LVM_ISGROUPVIEWENABLED = LVM_FIRST + 175;
     const int LVM_GETFOCUSEDCOLUMN = LVM_FIRST + 186;

     const int LVM_GETEMPTYTEXT = LVM_FIRST + 204;
     const int LVM_GETFOOTERRECT = LVM_FIRST + 205;
     const int LVM_GETFOOTERINFO = LVM_FIRST + 206;
     const int LVM_GETFOOTERITEMRECT = LVM_FIRST + 207;
     const int LVM_GETFOOTERITEM = LVM_FIRST + 208;
     const int LVM_GETITEMINDEXRECT = LVM_FIRST + 209;
     const int LVM_SETITEMINDEXSTATE = LVM_FIRST + 210;
     const int LVM_GETNEXTITEMINDEX = LVM_FIRST + 211;

    // calendar control specific constants taken from commctrl.h
    // commctrl MONTHCAL CONTROL win messages
     const int MCM_FIRST = 0x1000;
     const int MCM_GETCURSEL = (MCM_FIRST + 1);
     const int MCM_SETCURSEL = (MCM_FIRST + 2);
     const int MCM_GETMAXSELCOUNT = (MCM_FIRST + 3);
     const int MCM_GETSELRANGE = (MCM_FIRST + 5);
     const int MCM_SETSELRANGE = (MCM_FIRST + 6);
     const int MCM_GETMONTHRANGE = (MCM_FIRST + 7);
     const int MCM_GETMINREQRECT = (MCM_FIRST + 9);
     const int MCM_GETTODAY = (MCM_FIRST + 13);
     const int MCM_HITTEST = (MCM_FIRST + 14);
     const int MCM_GETFIRSTDAYOFWEEK = (MCM_FIRST + 16);
     const int MCM_GETRANGE = (MCM_FIRST + 17);
     const int MCM_SETMONTHDELTA = (MCM_FIRST + 20);
     const int MCM_GETMAXTODAYWIDTH = (MCM_FIRST + 21);
     const int MCM_GETCURRENTVIEW = (MCM_FIRST + 22);
     const int MCM_GETCALENDARCOUNT = (MCM_FIRST + 23);
     const int MCM_GETCALENDARGRIDINFO = (MCM_FIRST + 24);

    // PAGER CONTROL from commctrl.h 
     const int PGM_FIRST = 0x1400;
     const int PGM_SETCHILD = (PGM_FIRST + 1);
     const int PGM_RECALCSIZE = (PGM_FIRST + 2);
     const int PGM_FORWARDMOUSE = (PGM_FIRST + 3);
     const int PGM_SETBKCOLOR = (PGM_FIRST + 4);
     const int PGM_GETBKCOLOR = (PGM_FIRST + 5);
     const int PGM_SETBORDER = (PGM_FIRST + 6);
     const int PGM_GETBORDER = (PGM_FIRST + 7);
     const int PGM_SETPOS = (PGM_FIRST + 8);
     const int PGM_GETPOS = (PGM_FIRST + 9);
     const int PGM_SETBUTTONSIZE = (PGM_FIRST + 10);
     const int PGM_GETBUTTONSIZE = (PGM_FIRST + 11);
     const int PGM_GETBUTTONSTATE = (PGM_FIRST + 12);

    // SysTabControl32
     const int TCM_FIRST = 0x1300;
     const int TCM_GETITEMCOUNT = TCM_FIRST + 4;
     const int TCM_GETITEMRECT = TCM_FIRST + 10;
     const int TCM_GETCURSEL = TCM_FIRST + 11;
     const int TCM_SETCURSEL = TCM_FIRST + 12;
     const int TCM_HITTEST = TCM_FIRST + 13;
     const int TCM_GETTOOLTIPS = TCM_FIRST + 45;
     const int TCM_GETCURFOCUS = TCM_FIRST + 47;
     const int TCM_SETCURFOCUS = TCM_FIRST + 48;
     const int TCM_DESELECTALL = TCM_FIRST + 50;
     const int TCM_GETITEMW = TCM_FIRST + 60;

    // TreeView 
     const int TV_FIRST = 0x1100;
     const int TVM_EXPAND = (TV_FIRST + 2);
     const int TVM_GETITEMRECT = (TV_FIRST + 4);
     const int TVM_GETCOUNT = (TV_FIRST + 5);
     const int TVM_GETNEXTITEM = (TV_FIRST + 10);
     const int TVM_SELECTITEM = (TV_FIRST + 11);
     const int TVM_HITTEST = (TV_FIRST + 17);
     const int TVM_ENSUREVISIBLE = (TV_FIRST + 20);
     const int TVM_ENDEDITLABELNOW = (TV_FIRST + 22);
     const int TVM_GETTOOLTIPS = (TV_FIRST + 25);
     const int TVM_GETITEMSTATE = (TV_FIRST + 39);
     const int TVM_MAPACCIDTOHTREEITEM = (TV_FIRST + 42);
     const int TVM_MAPHTREEITEMTOACCID = (TV_FIRST + 43);
     const int TVM_GETITEMW = (TV_FIRST + 62);
     const int TVM_SETITEMW = (TV_FIRST + 63);
     const int TVM_EDITLABELW = (TV_FIRST + 65);

    // Window
     const int WM_SETTEXT = 0x000C;
     const int WM_GETTEXT = 0x000D;
     const int WM_GETTEXTLENGTH = 0x000E;
     const int WM_QUIT = 0x0012;
     const int WM_GETFONT = 0x0031;
     const int WM_GETOBJECT = 0x003D;
     const int WM_NCHITTEST = 0x0084;
     const int WM_KEYDOWN = 0x0100;
     const int WM_KEYUP = 0x0101;
     const int WM_COMMAND = 0x0111;
     const int WM_SYSCOMMAND = 0x0112;
     const int WM_HSCROLL = 0x0114;
     const int WM_VSCROLL = 0x0115;
     const int WM_LBUTTONDOWN = 0x0201;
     const int WM_LBUTTONUP = 0x0202;
     const int WM_RBUTTONDOWN = 0x0204;
     const int WM_RBUTTONUP = 0x0205;
     const int WM_MDITILE = 0x0226;
     const int WM_MDICASCADE = 0x0227;
     const int WM_HOTKEY = 0x0312;
     const int WM_GETTITLEBARINFOEX = 0x033F;
     const int WM_USER = 0x0400;

    // Dialog Codes
     const int WM_GETDLGCODE = 0x0087;
     const int DLGC_STATIC = 0x0100;

    // Slider
     const int TBM_GETPOS = WM_USER;
     const int TBM_GETRANGEMIN = WM_USER + 1;
     const int TBM_GETRANGEMAX = WM_USER + 2;
     const int TBM_SETPOS = WM_USER + 5;
     const int TBM_GETPAGESIZE = WM_USER + 22;
     const int TBM_GETLINESIZE = WM_USER + 24;
     const int TBM_GETTHUMBRECT = WM_USER + 25;
     const int TBM_GETCHANNELRECT = WM_USER + 26;
     const int TBM_GETTOOLTIPS = WM_USER + 30;

    // Progress Bar
     const int PBM_GETRANGE = (WM_USER + 7);
     const int PBM_GETPOS = (WM_USER + 8);

    // Status Bar
     const int SB_GETPARTS = (WM_USER + 6);
     const int SB_GETRECT = (WM_USER + 10);
     const int SB_GETTEXTLENGTHW = (WM_USER + 12);
     const int SB_GETTEXTW = (WM_USER + 13);

    // Rebar
     const int RB_HITTEST = WM_USER + 8;
     const int RB_GETRECT = WM_USER + 9;
     const int RB_GETBANDCOUNT = WM_USER + 12;
     const int RB_GETTOOLTIPS = WM_USER + 17;
     const int RB_GETBANDINFOA = WM_USER + 29;
     const int RB_PUSHCHEVRON = WM_USER + 43;

    // ToolBar
     const int TB_PRESSBUTTON = WM_USER + 3;
     const int TB_ISBUTTONENABLED = WM_USER + 9;
     const int TB_ISBUTTONCHECKED = WM_USER + 10;
     const int TB_ISBUTTONHIDDEN = WM_USER + 12;
     const int TB_GETBUTTON = WM_USER + 23;
     const int TB_BUTTONCOUNT = WM_USER + 24;
     const int TB_GETITEMRECT = WM_USER + 29;
     const int TB_GETTOOLTIPS = WM_USER + 35;
     const int TB_GETIMAGELIST = WM_USER + 49;
     const int TB_GETHOTITEM = WM_USER + 71;
     const int TB_SETHOTITEM = WM_USER + 72;
     const int TB_GETBUTTONTEXT = WM_USER + 75;
     const int TB_GETEXTENDEDSTYLE = WM_USER + 85;

    // Tooltip
     const int TTM_GETTOOLINFO = (WM_USER + 53);
     const int TTM_HITTEST = (WM_USER + 55);
     const int TTM_GETTEXT = (WM_USER + 56);
     const int TTM_GETCURRENTTOOL = (WM_USER + 59);

    // IPAddress
     const int IPM_SETADDRESS = (WM_USER + 101);

    //  SpinControl
     const int UDM_GETRANGE = (WM_USER + 102);
     const int UDM_SETPOS = (WM_USER + 103);
     const int UDM_GETPOS = (WM_USER + 104);
     const int UDM_GETBUDDY = (WM_USER + 106);

    // Hyperlink
     const int LM_FIRST = (WM_USER + 0x300);
     const int LM_HITTEST = LM_FIRST;
     const int LM_GETIDEALHEIGHT = (LM_FIRST + 1);
     const int LM_SETITEM = (LM_FIRST + 2);
     const int LM_GETITEM = (LM_FIRST + 3);


    // Button styles
     const int BS_PUSHBUTTON = 0x00000000;
     const int BS_DEFPUSHBUTTON = 0x00000001;
     const int BS_CHECKBOX = 0x00000002;
     const int BS_AUTOCHECKBOX = 0x00000003;
     const int BS_RADIOBUTTON = 0x00000004;
     const int BS_3STATE = 0x00000005;
     const int BS_AUTO3STATE = 0x00000006;
     const int BS_GROUPBOX = 0x00000007;
     const int BS_USERBUTTON = 0x00000008;
     const int BS_AUTORADIOBUTTON = 0x00000009;
     const int BS_PUSHBOX = 0x0000000A;
     const int BS_OWNERDRAW = 0x0000000B;
     const int BS_SPLITBUTTON = 0x0000000C;
     const int BS_TYPEMASK = 0x0000000F;

    // Date/Time picker styles
     const int DTS_UPDOWN = 0x0001;
     const int DTS_SHOWNONE = 0x0002;
    // DTS_TIMEFORMAT is wrongly defined in the common control include file with a value of 9
    // TIME_FORMAT + DTS_UPDOWN. 
     const int DTS_TIMEFORMAT = 0x0009;
    // Removes the UPDOWN bit. Use this const to check for TIMEFORMAT
     const int DTS_TIMEFORMATONLY = DTS_TIMEFORMAT & ~DTS_UPDOWN;

    // Dialogbox Styles
     const int DS_CONTROL = 0x00000400;

    // Editbox styles
     const int ES_LEFT = 0x0000;
     const int ES_CENTER = 0x0001;
     const int ES_RIGHT = 0x0002;
     const int ES_MULTILINE = 0x0004;
     const int ES_UPPERCASE = 0x0008;
     const int ES_LOWERCASE = 0x0010;
     const int ES_PASSWORD = 0x0020;
     const int ES_AUTOHSCROLL = 0x0080;
     const int ES_READONLY = 0x0800;
     const int ES_NUMBER = 0x2000;

    // Listbox styles
     const int LBS_NOTIFY = 0x0001;
     const int LBS_SORT = 0x0002;
     const int LBS_MULTIPLESEL = 0x0008;
     const int LBS_OWNERDRAWFIXED = 0x0010;
     const int LBS_WANTKEYBOARDINPUT = 0x0400;
     const int LBS_EXTENDEDSEL = 0x0800;
     const int LBS_COMBOBOX = 0x8000;

    // Listview styles
     const int LVS_REPORT = 0x0001;
     const int LVS_LIST = 0x0003;
     const int LVS_TYPEMASK = 0x0003;
     const int LVS_SINGLESEL = 0x0004;
     const int LVS_AUTOARRANGE = 0x0100;
     const int LVS_EDITLABELS = 0x0200;
     const int LVS_NOSCROLL = 0x2000;
     const int LVS_NOCOLUMNHEADER = 0x4000;

    // Listview extended styles
     const int LVS_EX_CHECKBOXES = 0x4;
     const int LVS_EX_FULLROWSELECT = 0x00000020;
     const int LVS_EX_ONECLICKACTIVATE = 0x00000040;
     const int LVS_EX_TWOCLICKACTIVATE = 0x00000080;
     const int LVS_EX_UNDERLINEHOT = 0x00000800;
     const int LVS_EX_UNDERLINECOLD = 0x00001000;
     const int LVS_EX_JUSTIFYCOLUMNS = 0x00200000; // Icons are lined up in columns that use up the whole view area

    // Listview item states
     const int LVIS_FOCUSED = 0x0001;
     const int LVIS_SELECTED = 0x0002;
     const int LVIS_STATEIMAGEMASK = 0xFFFF;

    // commctrl MONTHCAL CONTROL style constants
     const int MCS_DAYSTATE = 0x0001;
     const int MCS_MULTISELECT = 0x0002;
     const int MCS_WEEKNUMBERS = 0x0004;
     const int MCS_NOTODAYCIRCLE = 0x0008;
     const int MCS_NOTODAY = 0x0010;

    // PAGER CONTROL styles from commctrl.h
     const int PGS_VERT = 0x00000000;
     const int PGS_HORZ = 0x00000001;

    // Scrollbar style
     const int SBS_HORZ = 0x0000;
     const int SBS_VERT = 0x0001;

    // Slider style
     const int TBS_VERT = 0x0002;
     const int TBS_REVERSED = 0x0200;

    // Static styles
     const int SS_LEFT = 0x00000000;
     const int SS_CENTER = 0x00000001;
     const int SS_RIGHT = 0x00000002;
     const int SS_ICON = 0x00000003;
     const int SS_BLACKRECT = 0x00000004;
     const int SS_GRAYRECT = 0x00000005;
     const int SS_WHITERECT = 0x00000006;
     const int SS_BLACKFRAME = 0x00000007;
     const int SS_GRAYFRAME = 0x00000008;
     const int SS_WHITEFRAME = 0x00000009;
     const int SS_USERITEM = 0x0000000A;
     const int SS_SIMPLE = 0x0000000B;
     const int SS_LEFTNOWORDWRAP = 0x0000000C;
     const int SS_OWNERDRAW = 0x0000000D;
     const int SS_BITMAP = 0x0000000E;
     const int SS_ENHMETAFILE = 0x0000000F;
     const int SS_ETCHEDHORZ = 0x00000010;
     const int SS_ETCHEDVERT = 0x00000011;
     const int SS_ETCHEDFRAME = 0x00000012;
     const int SS_TYPEMASK = 0x0000001F;

    // SysHeader32 styles
    // const int HDS_HORZ = 0x0000;
     const int HDS_VERT = 0x0001;

    // Toolbar styles
     const int TBSTYLE_EX_DRAWDDARROWS = 0x00000001;

    // Toolbar button styles
     const byte BTNS_SEP       = 0x0001;
     const byte BTNS_CHECK     = 0x0002;
     const byte BTNS_GROUP     = 0x0004;
     const byte BTNS_DROPDOWN  = 0x0008;

    // Image list constants
     const int I_IMAGENONE = -2;

    // Window styles
     const int WS_OVERLAPPED    = 0x00000000;
     const int WS_TABSTOP       = 0x00010000;
     const int WS_MAXIMIZEBOX   = 0x00010000;
     const int WS_GROUP         = 0x00020000;
     const int WS_MINIMIZEBOX   = 0x00020000;
     const int WS_SYSMENU       = 0x00080000;
     const int WS_HSCROLL       = 0x00100000;
     const int WS_VSCROLL       = 0x00200000;
     const int WS_BORDER        = 0x00800000;
     const int WS_CAPTION       = 0x00C00000;
     const int WS_MAXIMIZE      = 0x01000000;
     const int WS_DISABLED      = 0x08000000; 
     const int WS_VISIBLE       = 0x10000000;
     const int WS_MINIMIZE      = 0x20000000;
     const int WS_CHILD         = 0x40000000;
     const int WS_POPUP         = unchecked((int)0x80000000);

    // Window extended sytles
     const int WS_EX_DLGMODALFRAME  = 0x00000001;
     const int WS_EX_MDICHILD       = 0x00000040;
     const int WS_EX_TOOLWINDOW     = 0x00000080;
     const int WS_EX_CONTEXTHELP    = 0x00000400;
     const int WS_EX_RTLREADING     = 0x00002000;
     const int WS_EX_CONTROLPARENT  = 0x00010000;
     const int WS_EX_LAYOUTRTL      = 0x00400000; // Right to left mirroring

    // Button states
     const int BST_UNCHECKED = 0x0000;
     const int BST_CHECKED = 0x0001;
     const int BST_INDETERMINATE = 0x0002;
     const int BST_PUSHED = 0x0004;
     const int BST_FOCUS = 0x0008;

    //GetDeviceCaps()
     const int LOGPIXELSX = 88;
     const int LOGPIXELSY = 90;

    // GetWindow()
     const int GW_HWNDFIRST = 0;
     const int GW_HWNDLAST = 1;
     const int GW_HWNDNEXT = 2;
     const int GW_HWNDPREV = 3;
     const int GW_OWNER = 4;
     const int GW_CHILD = 5;

    // GetWindowLong()
     const int GWL_EXSTYLE = (-20);
     const int GWL_STYLE = (-16);
     const int GWL_ID = (-12);
     const int GWL_HWNDPARENT = (-8);
     const int GWL_WNDPROC = (-4);

    // GetSysColor()
     const int COLOR_WINDOW = 5;
     const int COLOR_WINDOWTEXT = 8;

    // Mouse Key
     const int MK_LBUTTON = 0x0001;
     const int MK_RBUTTON = 0x0002;

    // Scrollbar
     const int SB_HORZ = 0;
     const int SB_VERT = 1;
     const int SB_CTL = 2;
     const int SB_LINEUP = 0;
     const int SB_LINELEFT = 0;
     const int SB_LINEDOWN = 1;
     const int SB_LINERIGHT = 1;
     const int SB_PAGEUP = 2;
     const int SB_PAGELEFT = 2;
     const int SB_PAGEDOWN = 3;
     const int SB_PAGERIGHT = 3;
     const int SB_THUMBPOSITION = 4;
     const int SB_THUMBTRACK = 5;
     const int SB_LEFT = 6;
     const int SB_RIGHT = 7;
     const int SB_ENDSCROLL = 8;
     const int SB_TOP = 6;
     const int SB_BOTTOM = 7;

     const int SORT_DEFAULT = 0x0;
     const int SUBLANG_DEFAULT = 0x01;

     const int SC_TASKLIST = 0xF130;

    // ShowWindow()
     const int SW_HIDE = 0;
     const int SW_NORMAL = 1;
     const int SW_SHOWMINIMIZED = 2;
     const int SW_SHOWMAXIMIZED = 3;
     const int SW_MAXIMIZE = 3;
     const int SW_SHOWNOACTIVATE = 4;
     const int SW_SHOW = 5;
     const int SW_MINIMIZE = 6;
     const int SW_SHOWMINNOACTIVE = 7;
     const int SW_SHOWNA = 8;
     const int SW_RESTORE = 9;
     const int SW_MAX = 10;

     const int SWP_NOSIZE = 0x0001;
     const int SWP_NOMOVE = 0x0002;
     const int SWP_NOZORDER = 0x0004;
     const int SWP_NOACTIVATE = 0x0010;
     const int SWP_SHOWWINDOW = 0x0040;
     const int SWP_HIDEWINDOW = 0x0080;
     const int SWP_DRAWFRAME = 0x0020;

    // System Metrics
     const int SM_CXSCREEN = 0;
     const int SM_CYSCREEN = 1;
     const int SM_CXVSCROLL = 2;
     const int SM_CYHSCROLL = 3;
     const int SM_CYCAPTION = 4;
     const int SM_CXBORDER = 5;
     const int SM_CYBORDER = 6;
     const int SM_CYVTHUMB = 9;
     const int SM_CXHTHUMB = 10;
     const int SM_CXICON = 11;
     const int SM_CYICON = 12;
     const int SM_CXCURSOR = 13;
     const int SM_CYCURSOR = 14;
     const int SM_CYMENU = 15;
     const int SM_CYKANJIWINDOW = 18;
     const int SM_MOUSEPRESENT = 19;
     const int SM_CYVSCROLL = 20;
     const int SM_CXHSCROLL = 21;
     const int SM_DEBUG = 22;
     const int SM_SWAPBUTTON = 23;
     const int SM_CXMIN = 28;
     const int SM_CYMIN = 29;
     const int SM_CXSIZE = 30;
     const int SM_CYSIZE = 31;
     const int SM_CXFRAME = 32;
     const int SM_CYFRAME = 33;
     const int SM_CXMINTRACK = 34;
     const int SM_CYMINTRACK = 35;
     const int SM_CXDOUBLECLK = 36;
     const int SM_CYDOUBLECLK = 37;
     const int SM_CXICONSPACING = 38;
     const int SM_CYICONSPACING = 39;
     const int SM_MENUDROPALIGNMENT = 40;
     const int SM_PENWINDOWS = 41;
     const int SM_DBCSENABLED = 42;
     const int SM_CMOUSEBUTTONS = 43;
     const int SM_CXFIXEDFRAME = 7;
     const int SM_CYFIXEDFRAME = 8;
     const int SM_SECURE = 44;
     const int SM_CXEDGE = 45;
     const int SM_CYEDGE = 46;
     const int SM_CXMINSPACING = 47;
     const int SM_CYMINSPACING = 48;
     const int SM_CXSMICON = 49;
     const int SM_CYSMICON = 50;
     const int SM_CYSMCAPTION = 51;
     const int SM_CXSMSIZE = 52;
     const int SM_CYSMSIZE = 53;
     const int SM_CXMENUSIZE = 54;
     const int SM_CYMENUSIZE = 55;
     const int SM_ARRANGE = 56;
     const int SM_CXMINIMIZED = 57;
     const int SM_CYMINIMIZED = 58;
     const int SM_CXMAXTRACK = 59;
     const int SM_CYMAXTRACK = 60;
     const int SM_CXMAXIMIZED = 61;
     const int SM_CYMAXIMIZED = 62;
     const int SM_NETWORK = 63;
     const int SM_CLEANBOOT = 67;
     const int SM_CXDRAG = 68;
     const int SM_CYDRAG = 69;
     const int SM_SHOWSOUNDS = 70;
     const int SM_CXMENUCHECK = 71;
     const int SM_CYMENUCHECK = 72;
     const int SM_MIDEASTENABLED = 74;
     const int SM_MOUSEWHEELPRESENT = 75;
     const int SM_XVIRTUALSCREEN = 76;
    // Stock Logical Objects
     const int SYSTEM_FONT = 13;        

     const int SM_YVIRTUALSCREEN = 77;
     const int SM_CXVIRTUALSCREEN = 78;
     const int SM_CYVIRTUALSCREEN = 79;

    // Virtal Keys
     const int VK_TAB = 0x09;
     const int VK_RETURN = 0x0D;
     const int VK_ESCAPE = 0x1B;
     const int VK_PRIOR = 0x21;
     const int VK_NEXT = 0x22;
     const int VK_F4 = 0x73;

     const int MAX_PATH = 260;

     const int MDITILE_VERTICAL = 0x0000;
     const int MDITILE_HORIZONTAL = 0x0001;
     const int MDITILE_SKIPDISABLED = 0x0002;

     const int S_OK = 0x00000000;
     const int S_FALSE = 0x00000001;
Scroll to Top