Skip to main content
gamedev.net
🔒 Locked

Drag-drop executing

Started by CyberSlag5k Apr 19, 2004 at 12:05 PM 9 replies 500+ views
Original Post
CyberSlag5k
CyberSlag5k
I use several programs that are run by dragging an input file on top of the executable. This intrigues me. How is it done? Does it just send the input file''s name to argv? Do you have to add something to the code to make it work, or does it work automatically? Thanks When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
Sneftel
Sneftel
Yep, the filename is just passed into the argument vector.


"Sneftel is correct, if rather vulgar." --Flarelocke
CyberSlag5k
CyberSlag5k
Cool. Thanks.

When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
CyberSlag5k
CyberSlag5k
Well, I have it working now so that it outputs argv. The only problem is, it outputs the entire file name, directory included. Is there a way I can have it cut off the directory? I suppose I could have it just clear out the string every time a \ is detected, but that feels a bit hacked. Is there a better way?

When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
ch1pz
ch1pz
Surely you want the directory? If the user drags a file on their desktop on a shortcut, you''d need the full path to load the file...
CyberSlag5k
CyberSlag5k
Well, I want to create variables and such just based on the file name.

When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.
psykr
psykr
Just snip it off yourself; it''s not that hard. Just cut off everything before the last ''\\'', making sure to snip off the last quotation mark if one exists.
SiCrane
SiCrane
Alternately if you use boost::filesystem, the path class has a leaf() member function that will return the file name without the rest of the directory path as a std::string object.
MauMan
MauMan
If you do not mind limiting yourself to windows only you can use PathStripPath().

[edited by - mauman on April 19, 2004 5:23:38 PM]
---CyberbrineDreamsSuspected implementation of the Windows idle loop: void idle_loop() { *((char*)rand()) = 0; }
CyberSlag5k
CyberSlag5k
Great. Thanks alot guys. I have it working now.

When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Without order nothing can exist - without chaos nothing can evolve.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.