If I got the other software's Menu handle,but i want to know Menu's MenuItem whether is checked state or unchecked state,how to use windows api to get the other software's MenuItem state.
 
[DllImport("user32.dll")]
public static extern int GetMenuState(int hMenu, int wID, int wFlags);
 
private int MF_BYPOSITION = 0x400;
 
int it = GetMenuState(menuHandle, 2, MF_BYPOSITION );
 
I'm sure the menuHandle value is correct,but return value it aways equals -1,i can't find out the reason.
can anybody help me?link url as follow:
http://www.codeproject.com/Questions/616259/how-to-use-Api-get-the-MenuItem-checked-state

解决方案 »

  1.   

            [System.Runtime.InteropServices.DllImport("user32.dll")]
            public static extern uint GetMenuState(IntPtr hMenu, uint wID, uint wFlags);
            private uint MF_BYPOSITION = 0x400;
            private uint MF_BYCOMMAND = 0xFFFFFFFF;
            //IntPtr menuHandle = IntPtr.Zero;
            uint it = GetMenuState(menuHandle, 2, MF_BYCOMMAND);
      

  2.   

    设置:BOOL EnableMenuItem(HMENU hMenu, UINT uIDEnableItem, UINT uEnable);    
    查询:UINT GetMenuState(HMENU hMenu, UINT uId, UINT uFlags);