0

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.

2
Contributors
2
Replies
22
Views
2 Years
Discussion Span
Last Post by markdean1989
0

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);
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.