Could someone tell me if there is anyway to pass the selected items(files) from Explorer to my Prog....Now I can retrieve the last item selected using the registry. ie shell -> command -> Prog %1. But if the user Selects multiple items(files) in Explorer the %1 can only send the first string to environment.getcmdargs...

i read a few lines about using the ishell approach but seems to elaborate for my needs....

just need to get selected items from explorer.. I'm thinking that there maybe some kind of add in/ext (dll) i could buy or use..just to get this thing Done....Or another way would be great....

like drag and drop ?

No,I'm using the windows registry...to provide a link to in windows right click context...so once you right lick on a file then it will run my prog with %1 (prog "selected file") but it only sends the selected file(hence %1) not multiple..

I dont see why you can only get 1 command line arg, while there is a limitation, you should be able to get the rest

it's seems that when i pass values using the right click context menu passing %1 to my prog only lets me get the last selected file in the explorers list....If manually pass the prog cmdline arguments like "c:\boot.ini" "c:\blah.txt" then it works. So it seems like explorers only sending the first string in the list...In other words I would need to do somehthing like prog %1 %2 %3 %4....(Not going to happen) so if there is another way that would be great..Ok just had a thought....May I could get parent handel and try and work it from the API show how....

You do need to handle the context for multiple selection differently than single connections in the code, I dont believe its the %1 persay thats the problem, I think its the code you use when you run it, I havent written such an app in c# however, I wrote one in win32, and I distinctly remember having a similar issue.

Whats the code you have? Are you testing to see if you were handed multiple files as while I dont have the code to hand, Id probably be able to spot something if I saw it.

Nah I'm pretty sure that its the "%1" only send the first string....But heres the code for the getcmdlines-

void getcmdLines()
    {
      string[] CMDAgru = Environment.GetCommandLineArgs();
       int cmdargs = 0;
           for (int i = 1; i != CMDAgru.Length; ++i)

so is there another command beside environmental variable %1

ok heres the gist....I have added a windows registry entry under hkey-class-root -> * so that when a "File" in explorer is selected with right click the the conext menu contains a link "which runs Myprog %1". the %1 sends the filename to Myprog....problem if a user has selected more than one file I need to send each file...(in theroy %1 %2 etc)... now c# envrioment.getcommandlineargs returns each string inputed manually (myprog "c:\blah.txt" "d:\autoexec.bat") just fine but explorer using the reg fix only seems to return the last selected file (index,%1)...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.