Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Friend Shared Function InsertMenuItem(ByVal hMenu As IntPtr, ByVal uItem As Integer,
ByVal fByPosition As Boolean, ByRef lpmii As MENUITEMINFO) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Friend Shared Function InsertMenu(ByVal hMenu As IntPtr, ByVal uPosition As Integer,
ByVal uFlags As Integer, ByVal uIDNewItem As Integer,
<MarshalAs(UnmanagedType.LPTStr)> ByVal lpNewItem As String) As Boolean
End Function
Notes:
User-Defined Types:
None.
Tips & Tricks:
Please add some!
Notes:
Be sure to always set SetLastError in your Win32 imports. The sample code below shows how you can make use of it.
Sample Code:
Please add some!
Tips & Tricks:
Without the CharSet attribute flag, the WinAPI may not know which underlying InsertMenu to call (the A version or the W version).
Alternative Managed API:
Do you know one? Please contribute it!
Sample Code:
C#:
if (!InsertMenu(hmenu, position++,
(uint)(MF.BYPOSITION | MF.SEPARATOR), id++, "Menu Item"))
throw new Win32Exception(Marshal.GetLastWin32Error());
Alternative Managed API:
None.
Click to read this page
5/16/2017 4:01:43 AM - anonymous
The InsertMenuItem API
3/16/2007 8:27:11 AM - -68.114.227.157
The SetLastError API
1/26/2016 3:27:33 AM - -124.148.167.58
Click to read this page
4/6/2008 7:23:14 AM - anonymous
The InsertMenuItem API
3/16/2007 8:27:11 AM - -68.114.227.157
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).