Win32API里的GetMenu改成C#里的格式如下:
[DllImport("user32.dll")]
static extern IntPtr GetMenu(IntPtr hWnd);现在窗口句柄已经取得,即:IntPtr hWnd已经取得,比如说是:mwh问:如何取得MenuStrip和ContextMenuStrip的句柄比如如下语句只能识别系统菜单,无法取得.net自建Form的MenuStrip和ContextMenuStrip的句柄
IntPtr hMainMenu = GetMenu(mwh);

解决方案 »

  1.   

    我也碰到这个问题,很sorry的是没解决用VS 2003的MainMenu就没任何问题
      

  2.   

    amandag:恩..昨天我还顶了你的帖子...
      

  3.   

    GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs.
      

  4.   

    fqj2004:Try to give us more info about it. I can't give you all the scores by this kind of answer. Although you have got the key point and gave us the suggestion. I'd like to give you the scores~
      

  5.   

    这样不就获取他们的句柄了吗!            
                IntPtr ii= this.menuStrip1.Handle;
                IntPtr cc = this.contextMenuStrip1.Handle;
    希望对你有所启示。有帮助。
      

  6.   

    http://tech.ddvip.com/2006-04/11444413204320.html
    把这篇文章看明白就应该会了.
    :),我也正在看...
      

  7.   

    这个问题解决了吗?有办法通过extern方式获取MenuStrip以及ToolStripMenuItem的句柄吗?