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 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
User-Defined Types:
None.
Notes:
Be sure to always set SetLastError in your Win32 imports. The sample code below shows how you can make use of it.
Tips & Tricks:
Without the CharSet attribute flag, the WinAPI may not know which underlying InsertMenu to call (the A version or the W version).
Sample Code:
C#:
if (!InsertMenu(hmenu, position++,
(uint)(MF.BYPOSITION | MF.SEPARATOR), id++, "Menu Item"))
throw new Win32Exception(Marshal.GetLastWin32Error());
Alternative Managed API:
None.
The InsertMenuItem API
10/10/2018 12:00:35 AM - -218.110.141.239
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
10/10/2018 12:00:35 AM - -218.110.141.239
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).