[ComImport(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
GuidAttribute("000214e4-0000-0000-c000-000000000046")]
public interface IContextMenu
{
[PreserveSig()]
int QueryContextMenu(
uint hMenu,
uint indexMenu,
int idCmdFirst,
int idCmdLast,
uint uFlags);
[PreserveSig()]
void InvokeCommand(IntPtr pici);
[PreserveSig()]
void GetCommandString(
int idcmd,
uint uflags,
int reserved,
StringBuilder commandstring,
int cch);
}
I found that GetCommandString gave me problems when defining the variable commandstring as a StringBuilder. (It had an unexplainable limit of 16 characters.) I found that by changing my definition to IntPtr, and then copying a string into this pointer by using lstrcpy works for the true buffer size designated by cch.