Share via

Visual studio visual c++ problem with command line args (macros)

2022-02-27T11:59:38.733+00:00

Hallo,

I have created a visual c++ app in visual studio 2010. I tried to pass some command line args which I set up in Project->Properties->Debugging, in particular some paths that required for the program to work ($(TargetPath) and $(ProjectDir)). See relevant code of the main class:

int main(array<System::String ^> ^args) //args is the array with the several paths I want to pass.
{
//MessageBox::Show(/args[0]/"1", "0.1", MessageBoxButtons::OK, MessageBoxIcon::Information);
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();

Application::SetCompatibleTextRenderingDefault(false);

// Create the main window and run it
Application::Run(gcnew Form1(args));
return 0;
}

When I run my app through visual studio the command line args are working properly and are passed into the software.
But when I install my software (through a set up I have created with visual studio) and trying to launch it, it seems that the command line args cannot be read properly, in particular whatever I have set in the command arguments textbox of the Project->Properties_>Debugging, I always take the $(TargetPath) and olny that. As a result the software fails to launch as it requires the other path too.

Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.


3 answers

Sort by: Most helpful
  1. RLWA32 52,566 Reputation points
    2022-02-28T00:30:07.91+00:00

    Actually the program creates some extention associated files (e.g. .rbd files) through a Save As button into which all progress is stored. So if I double click on such a file I want the program to be launched at the progress point of the last save as event. For all this to work I need somehow to capture the path of that file on double clicking it so that the software is able to open it and read the stored info

    In your setup project use the File Types editor to have the installer create your file type and associate the .rbd extension with the installed application. Refer to File Types Management in Deployment

    Was this answer helpful?

    0 comments No comments

  2. Γιάννης Χουζούρης 1 Reputation point
    2022-02-27T19:44:11.673+00:00

    Actually the program creates some extention associated files (e.g. .rbd files) through a Save As button into which all progress is stored. So if I double click on such a file I want the program to be launched at the progress point of the last save as event. For all this to work I need somehow to capture the path of that file on double clicking it so that the software is able to open it and read the stored info. This is all. I would be grateful if you have any ideas on how to solve this.

    Was this answer helpful?


  3. Γιάννης Χουζούρης 1 Reputation point
    2022-02-27T18:41:06.02+00:00

    Thank you for your answer, I' ve spent lots of time to see why the macros are not working in the installed software. My setup project creates a shortcut that works fine but I don't know how to set up these arguments in the setup project so that they can be stored into a string.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.