Associated project file startup

I need to get a file name of a project file, associated with my app, that is double-clicked or dropped on the app’s icon. Does Juce somehow allow it? I tried to retrieve it with getCommandLineParameters(), but unsuccesfully - it only works with command line.

JUCEApplication::anotherInstanceStarted()… ?

Doesn’t work either. In this case, it looks like this function isn’t called at all.

Well, I just double-checked this and the filename does get passed as the command line params. I’m using windows 7, but this has always worked. I’ve really no idea how you’d manage to get it to fail!

Looks extremely strange to me. I’m using WinXP and I have this func in my JUCEApplication class. So, what I tried is the following code:

        File f(commandLine);
        if(f.exists())
        {
            LoadProject(&f);
        }

And also, I tried to check whether it’s called at all with infinite loop inside it (while(1) {};), to make the app hang - no reaction in both cases. The app just normally starts. How did you check it on your side, Jules?

I made it pop up an alertwindow to display the command line. Have you actually looked at the command line string and seen that it’s empty?

In my case this function just doesn’t seem to be called, therefore popup code also doesn’t work - I tried it too, so the problem is not in commandLine string contents, but with function calls. I also can’t debug it with debugger since the app can’t be started inside MSVC environment. Any ideas how to debug or fix it would be greatly appreciated.

What function are you talking about?? I just put a popup in my application’s initialise method, which I can guarantee will be called!

Oh, I talked about anotherInstanceStarted(const String& commandLine) function.

Well, I checked the command line parameters in initialise() method and yes, there’s the absolute file path provided, but looks like this code can’t parse it to me:

File f(commandLine);
if(f.exists())
{
      LoadProject(&f);
}

I.e. f.exists() returns false, although commandLine contains correct file path. Hmm, need to investigate this more.

Well anotherInstanceStarted only gets called when… another instance is started. If your app isn’t already running when you drop the file, then it won’t get called.