Newbee question how to use JUCEApplication::getCommandLineParameterArray()

I want to use getCommandLineParameterArray() in my Gui application. But I alway’s get an empty array.

So I created a new console application just to test;

#include “…/JuceLibraryCode/JuceHeader.h”
#include

//==============================================================================
int main (int argc, char* argv)
{

std::cout << "argc =" << String(argc) << "\n";
for (int i = 0; i < argc; ++i) {
	std::cout << "argv param " << String(i) << " = " << argv[i] << "\n";
}

std::cout << "\nCommandline  = " << JUCEApplication::getCommandLineParameters();

StringArray commandline = JUCEApplication::getCommandLineParameterArray();
std::cout << "\nCommandline params = " << String(commandline.size()) << "\n\n";
for (int i = 0; i < commandline.size(); ++i) {
	std::cout << "Commandline param " << String(i) << " = " << commandline[i] << "\n";
}

return 0;

}

When I start it with “test.exe This is a test -h
The output is:
argc =6
argv param 0 = test.exe
argv param 1 = This
argv param 2 = is
argv param 3 = a
argv param 4 = test
argv param 5 = -h

Commandline =
Commandline params = 0

What am I doing wrong? And what is the best way to access command-line parameters in a Gui application?

You have to use the JUCEApplication class to make use of that API. Check out the basic GUI app tutorial: https://docs.juce.com/master/tutorial_main_window.html

Thank you. I got it working now.