In your code you have:
HINSTANCE ShellExecute(HWND, "open", szPath,"","",SW_SHOW);
That is a declaration of a function. I presume that you actually meant to call the function:
HINSTANCE retval = ShellExecute(HWND, "open", szPath,"","",SW_SHOW);
Now, that won't compile either. Since HWND
is a type. I think you need:
HINSTANCE retval = ShellExecute(0, "open", szPath, NULL, NULL, SW_SHOW);
What's more, there's no need to actually specify a verb. The default verb for a path will suffice.
HINSTANCE retval = ShellExecute(0, NULL, szPath, NULL, NULL, SW_SHOW);
And it sounds as though you are passing strings like this:
s.run("C:\Users\saira\...\phase_1_solver.exe");
That's not good because the backslash is used as the escape character in C++. So you need to escape it:
s.run("C:\\Users\\saira\\...\\phase_1_solver.exe");
If you are not going to test the return value then you can simply write:
ShellExecute(0, NULL, szPath, NULL, NULL, SW_SHOW);
If you do want to check for errors on return from ShellExecute
, then ShellExecute
is a bad function to call. Its error handling is particularly weak. Use ShellExecuteEx
instead. Raymond Chen discusses the error handling of ShellExecute
in Why does ShellExecute return SE_ERR_ACCESSDENIED for nearly everything?