Hi
I am working on a simple C++.Net project which will allow me to run another program (e.g., I. Ex., Word etc.).
However, I can't seem to find any working codes online.
Here are the codes I have found so far;

ShellExecute(GetDesktopWindow(), "open", "c:\myTestFolder\myfile.exe", NULL, NULL, SW_SHOWNORMAL);

requires the inclusion of the header Windows.h
The error that I get says "Argument of type Const Char is not compatible with parameter type LPCWSTR ????

System("iexplore.exe);

This is the code that I thought would accomplish this at first but also did not work. Error says "Not recognized as an internal or external command..."

Is it that complicated to run another app using C++?
I just migrated from Visual basic and it was so easy to accomplish this task with it.

You're compiling for Unicode, so Visual Studio is using LPCWSTR (Long Pointer to Constant Wide String) instead of the "normal" strings. Try prefixing your strings with an "L" to tell Visual Studio to convert the string. So:

    ShellExecute(GetDesktopWindow(), L"open", L"c:\myTestFolder\myfile.exe", NULL, NULL, SW_SHOWNORMAL);

I don't get why the black screen freezes whenever I run my program after inserting the code;

ShellExecute(GetDesktopWindow(), L"open", L"c:\myTestFolder\myfile.exe", NULL, NULL, SW_SHOWNORMAL);

And it works just fine whenever I remove it. Is there a solution for this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.