Jump to content
  • Advertisement
Sign in to follow this  
back2newbelf

drag and drop on exe's

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi first of all i'm using fstream and VS 6. i'm writing a program that takes a file(.html or .txt) and does some stuff with it(what exactly doesn't matter). problem is, if i want the program to process a different file i have to get into the code and change the line that specifies the file location and name. i want to be able to just drop the files on the exe, how can i do that?

Share this post


Link to post
Share on other sites
Advertisement
When you drop a file on top of an EXE, it passes the filename of that file in as the command-line parameter to that EXE.
Your program probably has a main() function that looks something like:
int main(int argc, char* argv[]) {

// ... code ...

return 0;
}

argc is the number of command line arguments passed to your program, and argv[] is an array of those command line arguments. In your example of just dropping a file onto an EXE, argc will be "2" and argv[1] will contain the filename of that file you just dropped on. (argv[0] contains the filename of the EXE file itself).

EDIT: Fixed. [embarrass]

[Edited by - benryves on August 10, 2005 4:39:43 AM]

Share this post


Link to post
Share on other sites
or if the application is already open you will need to implement drag and drop for that application's window to accept the dropping of files.

There are many articles on this - i would be glad to give you some pointers if you can tell me what architecture you are using (ie. Win32 or MFC).

Share this post


Link to post
Share on other sites
thanks guys, benryves already answered what i needed to know.
just to clear things up(because i got it wrong the firs time):
argv[0] is the path of the exe
argv[1] is the path of the file you dropped on the exe

Share this post


Link to post
Share on other sites
Quote:
Original post by back2newbelf
argv[0] is the path of the exe
argv[1] is the path of the file you dropped on the exe
When I got home last night I suddenly remembered that I'd made the cock-up... glad you worked it out, in that case [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!