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 Interfaces, prefix the name with the module name and a period.
IContextMenu (Interfaces)
.
C# Definition:
public interface IContextMenu3 : IContextMenu2 {
[PreserveSig] int HandleMenuMsg2( uint uMsg, uint wParam, uint lParam, IntPtr plResult );
}
VB Definition:
<ComImport> _
<Guid("TODO")> _
'TODO: Insert <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ if this doesn't derive from IDispatch
Interface IContextMenu3
TODO
End Interface
User-Defined Types:
None.
C# Signature:
[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);
Notes:
[PreserveSig()]
void InvokeCommand(IntPtr pici);
Make sure your object explicitly lists all the IContextMenu interfaces or the shell may never call IContextMenu3.HandleMenuMsg2. For example:
[PreserveSig()]
void GetCommandString(
int idcmd,
uint uflags,
int reserved,
StringBuilder commandstring,
int cch);
}
VB Signature:
<ComImport()> _
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
<GuidAttribute("000214e4-0000-0000-c000-000000000046")> _
Public Interface IContextMenu
<PreserveSig()> _
Function QueryContextMenu( _
ByVal hMenu As Integer, _
ByVal indexMenu As Integer, _
ByVal idCmdFirst As Integer, _
ByVal idCmdLast As Integer, _
ByVal uFlags As Integer) As Integer
<PreserveSig()> _
Sub InvokeCommand(ByVal pici As IntPtr)
<PreserveSig()> _
Sub GetCommandString( _
ByVal idcmd As Integer, _
ByVal uflags As Integer, _
ByVal reserved As Integer, _
ByVal commandstring As StringBuilder, _
ByVal cch As Integer)
End Interface
In process shell extensions should never be written in managed code. There is no way for this to work correctly in all cases. Managed code may call shell extensions but cannot be used to implement them.
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.
Hint:
You may have to explicitly call lstrcpynW or lstrcpynA based uFlags
Sample Code:
void IContextMenu.GetCommandString(int idCmd, uint uFlags, int reserved, IntPtr commandString, int cchMax)
{
string commandStr = "" ;
if ((uFlags & (uint)GCS.VERB) != 0)
{
//obviously you could insert some cases here
switch (idCmd)
{
default:
commandStr = "...";
break;
}
}
if((uFlags & (uint)GCS.HELPTEXT) != 0)
{
switch (idCmd)
{
case 0:
commandStr = "Menu Item 1. And a brief description of what it does.";
break;
case 1:
commandStr = "Menu Item 2. And a brief description of what it does." ;
break;
case 2:
commandStr = "Menu Item 3. And a brief description of what it does.";
break;
case 3:
commandStr = "Menu Item 4. And a brief description of what it does.";
break;
default:
commandStr = "...";
break;
}
}
// must limit the return string to cchMax
if (commandStr.Length >= cchMax) commandStr = commandStr.Substring(0, cchMax-1) ;
// now return unicode or ansi based on uFlags
if((uFlags & (uint)GCS.UNICODE) != 0 )
{
str = Marshal.StringToHGlobalUni(commandStr);
Helpers.lstrcpynW(commandString, str, cchMax);
Marshal.FreeHGlobal(str);
}
else
{
str = Marshal.StringToHGlobalAnsi(commandStr);
Helpers.lstrcpynA(commandString, str, cchMax);
Marshal.FreeHGlobal(str);
}
}
TODO - a short description
3/16/2007 7:48:22 AM - -12.170.217.217
TODO - a short description
12/21/2021 5:48:02 AM - 141.98.9.24
TODO - a short description
3/16/2007 7:48:22 AM - -12.170.217.217
TODO - a short description
12/16/2008 12:03:53 PM - 65.54.188.148
TODO - a short description
3/16/2007 7:48:22 AM - Roland Berktold-80.132.82.238
Click to read this page
10/2/2011 2:35:57 AM - txzhgh-89.110.151.174
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
The lstrcpyn API
3/16/2007 7:56:45 AM - -104.180.240.187
Please edit this page!
Do you have...
helpful tips?
corrections to the existing content?
alternate definitions?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.