I would like to select several files on my desktop (or any other folder) and pass their names to my applicati开发者_如何学运维on.
More specifically, I've added a key to the registry such that when I right click on a jpeg file I see a new "Transform" option that actually runs my application. The question is how can I pass all selected files names to my application ?
Thanks a lot !
They should be passed by windows. Look at the command line arguments passed to your application at start up. ie. in your Main function that has a parameter of string[] args.
To illustrate:
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Program called without arguments");
}
else
{
Console.WriteLine("Program received this arguments:");
foreach (string arg in args)
{
Console.WriteLine("\t{0}", arg);
}
}
// .. do other stuff
}
If this is something that you want to do while your app is already running, like for example via a drag/drop type operation then there are a few API calls that allow you to perform drag and drop type operations with Shell objects.
Lookup/google IDragSourceHelper, IDropTargetHelper, IDataObject etc.
精彩评论