#include <iostream>
#include <windows.h>
#include <string>
using namespace std;

void main() 
{
    string run;
    cin >> run;
    ShellExecute(NULL, NULL, run /*<<<the error*/, NULL, NULL, SW_SHOWNORMAL);

}

I want it so if i enter a file path, it open.

If i replace run with "E:/test.exe", it works... but i want it so i can enter any file path...

Recommended Answers

All 2 Replies

More than likely ShellExecute take a const char array. If that is the case try

ShellExecute(NULL, NULL, run.c_str(), NULL, NULL, SW_SHOWNORMAL);

Thank you very much!

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.