none
How to get past 16 file limit of DragQueryFile for shell extensions in windows 7? RRS feed

  • Question

  • I posted this in the C# General area, but this is the right place for it.

    I ran into the same issue as this guy:
    http://stackoverflow.com/questions/2363911/shell-extension-dragqueryfile-returns-at-most-16-in-windows-7

    it mentions to look at this:
    http://msdn.microsoft.com/en-us/library/dd758093%28VS.85%29.aspx

    I did, and do not understand how to get the full list of files in the verb invoke:
    "In Windows 7 and later, the number of items passed to a verb is limited to 16 when a shortcut menu is queried. The verb is then re-created and re-initialized with the full selection when that verb is invoked."

    I'm not an expert in shell extensions, but I can almost see what is going on from lots of examples.
    Eevery example seems to collect a list of selected items in the Initialize event.  This is exactly where only 16 files are gathered.
    I need to re-do that in the invoke method to get all files selected, right?

    I cannot do this though because the initialize method has a parameter "data" as seen in the method definition:
    public void Initialize( IntPtr pidlFolder, IDataObject data, int hkeyProgID )
    that gets used in this line:
    data.GetData(ref FMT, ref STM);
    int count = DragQueryFile(STM.data, 0xffffffff, null, 0);

    So I want to run that code again in the InvokeCommand method, but the IDataObject data is not available.
    I would imagine it would do no good to store the original data object as a private var for later usage, as it only has the 16 names.

    The InvokeCommand method looks like this:
    public void InvokeCommand( ref CMINVOKECOMMANDINFO lpici )

    When would i get the opportunity to get the full list of files?


    James Maeding
    Tuesday, April 5, 2011 12:02 AM

All replies

  • You can run another shell extension (a BHO that gets loaded in explorer.exe, for example) to get the full selected item list when you ask via IPC methods like named pipe or RPC.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, April 5, 2011 12:28 AM
  • can you expand those acronyms?  may be a bad sign I am asking that :)
    James Maeding
    Tuesday, April 5, 2011 1:05 AM
  • BHO stands for Browser Helper Object. You can write one as the back door to the active Shell view

    IPC stands for inter-processs communication. You can find examples of IPC at http://1code.codeplex.com/wikipage?title=IRPC



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, April 5, 2011 2:05 AM
  • thanks. That is a whole can of worms given i am not a C++ programmer.  I understand it, but cannot author it.

    This may change though....


    James Maeding
    Tuesday, April 5, 2011 4:40 PM
  • Those are language-independent Windows APIs, you can use them in any language if the language's type system supports Windows SDK types. 

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, April 5, 2011 5:14 PM
  • The question remains, How do I get the full selected file list during the CommandInvoke of the context menu command?

    Recall from help " The verb is then re-created and re-initialized with the full selection when that verb is invoked."

    I am not understanding how to do that, as the invokecommand does no pass in the required objects.  I have found no examples on this as everyone seems to save the list of files from the first time the contextmenu was initialzed.


    James Maeding
    Wednesday, April 6, 2011 6:26 PM
  • I did some more testing, and added debug "print" statements instead of actually stopping code.

    That revealed something totally different than expected.  The contextmenu object is initializing once before the context menu is shown (as expected) , then another time when you click on an item (as MS said it would).

    It gets all the items the second init, so that makes sense.  But then it runs another (third) time when more than 16 items were selected.  When it does, it only gets the first item selected.

    So now I am wondering why the contextmenu object initializes two times after a command is picked.  Once I figure that out, I bet it will tell me what to fix.

     


    James Maeding
    Wednesday, April 6, 2011 9:50 PM
  • I thought I just figured out a workaround, by setting:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer MultipleInvokePromptMinimum to 16.

    Dang! does not seem to affect the 16 file limit of menu extensions, just the built-in open, print...and other MS ones.

    Am I on the right track?  Is that reg key only for MS stuff?

    Again, my problem at this point is the contextmenu re-initializes twice after the command is picked.  I cannot seem to figure out why, but the second time it sees no items selected so no commandinvoke happens.


    James Maeding
    Thursday, April 7, 2011 12:19 AM