im trying to create a program that executes an .exe file.
It reads the path from an .ini file.
The ini file contents are read and saved to a variable.
Now: How do I get ShellExecute() to use the variable as the path?
Thanks in advance !
Heres the part of my code:
1 2 3 4
//path is declared as a string variable, <string.h> is included
ShellExecute(GetDesktopWindow(), TEXT("open"), TEXT(path), NULL, NULL, SW_SHOWNORMAL);;
//The TEXT(path) part is the problem, as it cant use a variable :(
Ok...but when I add .c_str() It doesnt change anything...
And when I cange the variable to char it (of course) only reads the first letter one; a loop doesnt help either.
Where sould I use the .c_str()? It doesnt work in the declarition.
Thanks again!
ps.: Im sorry if this is kind of a "noob" topic; but this is my first use of ShellExecute().
I thought i'd offer a bit more explanation as to why that worked.
Windows.h defines 2 types of almost every function in the header. One is Unicode(hence the W for wide at the end of the name), and the other is ANSI(hence the A at the end of the name).
Windows.h checks to see if you have defined Unicode, and then picks the appropriate function for you.
If you are using Visual Studio, go into your project settings and turn Unicode off to fix this permanently.
With your explanations i have managed to create a program that reads the file path from an ini file, saves it to a string variable and then executes it. :)