在资源管理器添加的右键菜单在Win7 x86上可以,但在win2008 x64上不行。
----------------这是源码
int IContextMenu.QueryContextMenu(uint hmenu,uint iMenu, int idCmdFirst,int idCmdLast,uint uFlags)
{
// The first id to use (should be 1)
int id = 1;
if ((uFlags & 0xf) == 0 || (uFlags & (uint)CMF.CMF_EXPLORE) != 0)
{
// Create a new Menu Item to add to the context menu
MENUITEMINFO mii = new MENUITEMINFO();
mii.cbSize = 48;
mii.fMask = (uint)MIIM.ID | (uint)MIIM.TYPE | (uint)MIIM.STATE;
mii.wID = idCmdFirst + id;
mii.fType = (uint)MF.STRING;
mii.dwTypeData = "Send file(s) to CheapFTP member(s)";
mii.fState = (uint)MF.ENABLED;
// Add it to the item
DllImports.InsertMenuItem(hmenu, (uint)2, 1, ref mii); id = 2;
// Create a new Menu Item to add to the context menu
MENUITEMINFO miii = new MENUITEMINFO();
miii.cbSize = 48;
miii.fMask = (uint)MIIM.ID | (uint)MIIM.TYPE | (uint)MIIM.STATE;
miii.wID = idCmdFirst + id;
miii.fType = (uint)MF.STRING;
miii.dwTypeData = "Quick Send file(s) to CheapFTP preferred member(s)";
miii.fState = (uint)MF.ENABLED;
// Add it to the item
DllImports.InsertMenuItem(hmenu, (uint)2, 1, ref miii); id = 3;
// Create a seperator
MENUITEMINFO sep = new MENUITEMINFO();
sep.cbSize = 48;
sep.fMask = (uint)MIIM.TYPE;
sep.wID = idCmdFirst + id;
sep.fType = (uint)MF.SEPARATOR;
// Add it to the seperator to the context menu
DllImports.InsertMenuItem(hmenu, (uint)2, 1, ref sep);
}
// Return the number of items added
return id;
}
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:
MessageBox.Show("Shell Error");
break;
}
}
catch(Exception e)
{
System.Windows.Forms.MessageBox.Show("Error : " + e.ToString(),
"Error in CheapFTP installation. Please re-install.");
}
}
----------------这是源码
int IContextMenu.QueryContextMenu(uint hmenu,uint iMenu, int idCmdFirst,int idCmdLast,uint uFlags)
{
// The first id to use (should be 1)
int id = 1;
if ((uFlags & 0xf) == 0 || (uFlags & (uint)CMF.CMF_EXPLORE) != 0)
{
// Create a new Menu Item to add to the context menu
MENUITEMINFO mii = new MENUITEMINFO();
mii.cbSize = 48;
mii.fMask = (uint)MIIM.ID | (uint)MIIM.TYPE | (uint)MIIM.STATE;
mii.wID = idCmdFirst + id;
mii.fType = (uint)MF.STRING;
mii.dwTypeData = "Send file(s) to CheapFTP member(s)";
mii.fState = (uint)MF.ENABLED;
// Add it to the item
DllImports.InsertMenuItem(hmenu, (uint)2, 1, ref mii); id = 2;
// Create a new Menu Item to add to the context menu
MENUITEMINFO miii = new MENUITEMINFO();
miii.cbSize = 48;
miii.fMask = (uint)MIIM.ID | (uint)MIIM.TYPE | (uint)MIIM.STATE;
miii.wID = idCmdFirst + id;
miii.fType = (uint)MF.STRING;
miii.dwTypeData = "Quick Send file(s) to CheapFTP preferred member(s)";
miii.fState = (uint)MF.ENABLED;
// Add it to the item
DllImports.InsertMenuItem(hmenu, (uint)2, 1, ref miii); id = 3;
// Create a seperator
MENUITEMINFO sep = new MENUITEMINFO();
sep.cbSize = 48;
sep.fMask = (uint)MIIM.TYPE;
sep.wID = idCmdFirst + id;
sep.fType = (uint)MF.SEPARATOR;
// Add it to the seperator to the context menu
DllImports.InsertMenuItem(hmenu, (uint)2, 1, ref sep);
}
// Return the number of items added
return id;
}
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:
MessageBox.Show("Shell Error");
break;
}
}
catch(Exception e)
{
System.Windows.Forms.MessageBox.Show("Error : " + e.ToString(),
"Error in CheapFTP installation. Please re-install.");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货