Hi, i'm having a little problem with my context menu handler.
Basically if i select multiple files and right-click OPEN or EDIT, it
uses my context menu to open it. It is because i am missing this line
of code of C++ in my C# code.
-------------------------
// If lpVerb really points to a string, ignore this function call and
bail out.
if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;
---------------------------
Here is the C++ example code to bring up a mesage box:
HRESULT CDLLRegShlExt::InvokeCommand ( LPCMINVOKECOMMANDINFO pInfo )
{
// If lpVerb really points to a string, ignore this function call
and bail out.
if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;
// Check that lpVerb is one of our commands (0 or 1)
switch ( LOWORD( pInfo->lpVerb ))
{
case 0:
case 1:
{
CProgressDlg dlg ( &m_lsFiles, pInfo );
dlg.DoModal();
return S_OK;
}
break;
default:
ATLASSERT(0); // should never get here
return E_INVALIDARG;
break;
}
}
------------------------
HERE is my C# code to call a custom app:
void IContextMenu.InvokeCommand(IntPtr pici)
{
try
{
//fileList
StringBuilder fileList = new StringBuilder();
StringBuilder sb = new StringBuilder(1024);
uint i = 0;
//Get number of files
uint uNumFiles = 0;
uNumFiles = DllImports.DragQueryFile(m_hDrop, 0xFFFFFFFF, null,
0);
//make file name
while (i < uNumFiles)
{
DllImports.DragQueryFile(m_hDrop, i, sb, sb.Capacity + 1);
fileList.Append(sb + ",");
i++;
}
// Determine which of the context menus was clicked
Type t = Type.GetType("ShellExt.INVOKECOMMANDINFO");
INVOKECOMMANDINFO ici;
ici = (INVOKECOMMANDINFO)Marshal.PtrToStructure(pici, t);
switch (ici.verb - 1)
{
case 0:
// Send File(s) to CheapFTP client
Process.Start("c:\\CheapFTP.exe", "\"" +
fileList.ToString() + "\"");
break;
case 1:
// Send File(s) to CheapFTP client with QuickSend Flag
enabled
fileList.Append("QuickSend,");
Process.Start("c:\\CheapFTP.exe", "\"" +
fileList.ToString() + "\"");
break;
default:
break;
}
}
How can i get
if ( 0 != HIWORD( pInfo->lpVerb ))
return E_INVALIDARG;
into C#, as i know the "pInfo" of the C++ is the equivalent to the
"ici" in my C# code so it "bails out" and returns the E_INVALID arg so
it will OPEN or EDIT the file with the proper program?