Question about launching an application ...

BlitzMax Forums/BlitzMax Programming/Question about launching an application ...

mic_pringle(Posted 2010) [#1]
Hi,

I would like to know if it's possible to associate a file type with the application you produce with BlitzMax, and then have it open this application and use that file in someway when you double click on the file ?

A quick example to make this clearer would be when you double click on a text file, your favourite text editor opens up and then loads the contents of that text file.

Coming from a Mac development background I know how to do this in a Cocoa application ...

- Define the file type associated with the application in the applications property list file
- In your application delegate you define the function
- (BOOL)application: (NSApplication * )theApplication openFile: (NSString * )filename;
and then you can handle the file as you wish because you are passed the full file path

Is there anyway to achieve the same thing in BlitzMax, either using MaxGUI, wxMax or just standard BlitzMax ?

Thanks

-Mic


Arowx(Posted 2010) [#2]
Found this link on Microsoft website http://support.microsoft.com/kb/185453

Looks like you need to set up a link in the registry settings, an installer on windows should allow you to do this.

And there is this code in the archives which might help: http://www.blitzbasic.com/codearcs/codearcs.php?code=1991

Hope this helps!


mic_pringle(Posted 2010) [#3]
Arowx

Thanks for this, but unfortunately it only answers half the problem (and is windows specific).

It shows how to associate file types with the application, but not how to handle the file that launched the application once it has been launched.

Thanks

-Mic


Arowx(Posted 2010) [#4]
The file and it's location should appear in the AppArgs array.

The OS should launch a new instance of the app with the file details as an string in the appargs array.


mic_pringle(Posted 2010) [#5]
Aha! I did not know this :-)

Can you give me any examples or point to any documentation about the AppArgs array ?

Thanks

-Mic


Arowx(Posted 2010) [#6]
It's in the help...

Print "Number of arguments = "+AppArgs.length

For a$=EachIn AppArgs
Print a$
Next