-1

I have a C++/CLI WinForms project and in which I can happily print out the command line arguments in main using the following code

int main(array<System::String ^> ^args)
{
    for each(String^ arg in args) {
        System::Diagnostics::Debug::WriteLine(arg);
    }
}

Is there a built in function that allows me to access these arguments again during the program or do I need to save them myself?

I've seen this question, specifically the second answer that says you can do this in C#:

string[] args = Environment.GetCommandLineArgs();

But is there a way specifically in C++/CLI?

GPPK
  • 6,546
  • 4
  • 32
  • 57
  • Possible duplicate of [How do I pass command-line arguments to a WinForms application?](https://stackoverflow.com/questions/1179532/how-do-i-pass-command-line-arguments-to-a-winforms-application) – Tom Blodget Feb 13 '18 at 11:14
  • @TomBlodget I think whilst similar, it is a different language so *ever so slightly* different in the function call and return object – GPPK Feb 13 '18 at 11:16
  • It's the same .NET question with the same .NET BCL answer(s). Not even Microsoft duplicates their .NET documentation for different programming languages. Having separate questions dilutes the answers. – Tom Blodget Feb 13 '18 at 12:25

1 Answers1

0

The second part of my question is available in C++/CLI, you can do it like so:

array<System::String ^> ^args = System::Environment::GetCommandLineArgs();
GPPK
  • 6,546
  • 4
  • 32
  • 57