Associated project file startup


#1

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.


#2

JUCEApplication::anotherInstanceStarted()… ?


#3

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


#4

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!


#5

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?


#6

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?


#7

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.


#8

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


#9

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.


#10

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.