0

It's easy to add the app in the "Send To" folder. But once you select a file --> send to --> your app, the app just opens.

image

In the above picture, once I click on "Your App", the app opens, but how do I get the absolute path of the file that is selected? I can't find anything related to this.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770

1 Answers1

0

The file name is probably the first argument, which is used, when your application is called.

Your main function has to look like this:

int main(int argc, char *argv[])

Then argc is the count of arguments and argv an array of null terminated strings.

The first argument would be accessed like this:

argv[1];

But don't forget to check argc first:

char* cFile=0;
if(argc==1) {
   cFile=argv[1];
}
if(cFile) {
 //do action with file here
}
Norbert Willhelm
  • 2,579
  • 1
  • 23
  • 33
  • But where do I find the first argument? is there something I need to add in main.cpp to get the file name/ file path – vinayak sankeet May 23 '21 at 19:53
  • The last command line position `argc - 1` where the parameter sent by "Send To" folder resides are something contained full path. You can use `PathCchRemoveFileSpec` to get file path or use `_splitpath_s` to get the file name and file path. – YangXiaoPo-MSFT May 24 '21 at 03:30