|
|||
|
Hi
How do I let an application carry out a function on a file when it is opened with the application? Bit hard to explain, so an example: I want MyApplication to read MyFile. So I right click MyFile and select 'open with' then choose MyApplication. MyApplication should then open and carry out a function on MyFile to read it. I expect that this is in the manual, but I can't seem to find it. Help appreciated. ~Mark |
|
|||
|
1. Use the Application.associate method to associate your file with your application. Then when you double click the file in the Windows Explorer, your application will be launched to open the file. In this case, the Windows explorer just passes the name of the file as a command line parameter to your application
2. Handle the command line parameter Code:
var cmdItems = Application.cmdItems;
if (cmdItems.length > 0)
{
var filename = cmdItems[0];
Dialogs.msgBox(filename + " is opened!");
}
|
|
|||
|
Hi thanks for the help, that's what I was looking for.
But for some reason it still wont work: Code:
Application.associate('.ccg', "Demo.type");
var cmdItems = Application.cmdItems;
if (cmdItems.length > 0)
{
//cmdItems[0] is the name of the file
Dialogs.msgBox(cmdItems[0]);
}
Thanks, Mark |
|
|||
|
We have tested it and find that it works.
Code:
Application.associate(".ccg", "CCg.type");
var cmdItems = Application.cmdItems;
if (cmdItems.length > 0 && cmdItems[0] != "con")
{
//cmdItems[0] is the name of the file
Dialogs.msgBox(cmdItems[0]);
}
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|