C++ - Accessing a file that was "dropped" on the executable
I have used a number of programs where I am able to use the programs functions by simply dragging and dropping a file onto the executable. For example, if there is a program that formats text files, simply dragging a text file onto the executable will 开发者_开发百科make it run and use the text file as the target.
What does the main function look like for a program that allows this?
Dropped files are usually just given as command line parameters to the program:
int main(int argc, char** argv)
{
if (argc > 1)
{
// do sth. with argv[1] == first dropped file name
}
}
精彩评论