File type associations and opening when files are dragged.

Discussion about everything. New games, 3d math, development tips...
Post Reply
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

File type associations and opening when files are dragged.

Post by 3DModelerMan »

How do you associate file types with your application? I need to do it for windows, and linux, and mac. And also, how do you make the files open when they are dragged to the program's icon?
Thanks.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

how do you make the files open when they are dragged to the program's icon
Filename is in the main function argument parameter.
For the association stuff, I guess it happen in the register.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Re: File type associations and opening when files are dragge

Post by slavik262 »

3DModelerMan wrote:How do you associate file types with your application? I need to do it for windows, and linux, and mac.
Not sure how with *nix systems, but with Windows it's stored in the registry.
3DModelerMan wrote:And also, how do you make the files open when they are dragged to the program's icon?
Thanks.
When you drag a file onto a program or its icon, the file name and path of the dragged file are sent to the program as a command line argument.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Code: Select all

int main( int argc, const char* argv[] )
So like slavik said, it's passed as a command line argument. argc will give the the number of arguments, and argv will be an array of strings with the actual arguments (in your case, must likely a path to the file)
Post Reply