I created this code which allows the user to open file such as notepad++, excel, etc'. And I want to check if he opened a file that exists. If not just give an error message. If it is a file print "it works" or something like that.
The answer that you gave me is completely unrelated, it's about something else with a different function, it's too general.
Iv'e tried to check if the file is true but it doesn't work.
if (qorn == "notreal" || qorn == "4") {
if (fileopen("ex") == true) { // all ways true ex is not a real file
cout << "The file is good";
}
else {
cout << "you don't have this file";
}
}
bool fileopen(string url) {
bool f = false;
// .exe etc
// what to do with the file - open is default
// what is the name of the file you want to do something with
ShellExecuteA(NULL,NULL/*null- open it as a deffualt*/, url.c_str(), NULL, NULL, SW_SHOWNORMAL);
if (ShellExecuteA(NULL, NULL, url.c_str(), NULL, NULL, SW_SHOWNORMAL)) {
f = true;
}
return f;
}
> You adviced me to this this as well which returns 000002 at the end if
> i print it
HINSTANCE fileopen(string url) {
HINSTANCE num = 0;
// .exe etc
// what to do with the file - open is deffualt
// what is the name of the file you want to do wsomething with
num =ShellExecuteA(NULL,NULL/*null- open it as a deffualt*/, url.c_str(), NULL, NULL, SW_SHOWNORMAL);
return num;
}