Good day! I just can not figure out how to run an external program in Visual C ++. All that I found in the internet - does not work.

My code is:

#include <windows.h> using namespace System; using namespace System::Reflection; using namespace System::Windows::Forms; using namespace Microsoft::Win32; [STAThread] void Main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); String^ InstallPath = nullptr; RegistryKey^ rk = nullptr; rk = Registry::LocalMachine->OpenSubKey("SOFTWARE\\MCFR\\KozaDisk"); if (rk != nullptr) { array<String^>^ name = rk->GetValueNames(); for (int i = 0; i < name->Length; i++) { String^ value = rk->GetValue(name[i])->ToString(); if (name[i] == "InstallPath") InstallPath = value; } } if (InstallPath != nullptr) { String^ AppPath = InstallPath + "Koza.exe"; // запускаСм ΠΏΡ€ΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ AppPath } else { MessageBox::Show("Install"); } } 

The variable String ^ AppPath is the full path to the application to be launched. How can I do it?

Thank you in advance!!

  • "How can I do it?" - To look in any reference on the functions of Windows? - PinkTux
  • CreateProcess can still be used ... - Vladimir Martyanov

1 answer 1

This is done like this:

 System::Diagnostics::Process::Start(AppPath); 

Note that you are not writing in C ++ at all. You write in C ++ / CLI, a C ++ extension for .NET. It is a completely different language.

  • Thanks, it turned out! - Yury