0) What exactly happens when you run this programm?
1) Do you really run this program from desktop?
2) Did you check if file is open with .is_open()?
3) If not, what is errno is?
4) What is the return value of shell execute is?
Ok, YES, the program is being run from the desktop, when I run the program, It says, Please enter input: which i do then press enter, then it says, type open to show ur contents, so then i type: open. then nothing happens. however if i look at the text file, the input i entered was saved to that file. and no i have not check with .is_open(), and i dont know what the return value is
If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below.
Additionally, as you are saving and reading from file in your working directory, absolute path is unnessesary. You can write ShellExecute(NULL, "open", "PASSWORD_FILE.txt", NULL, NULL, 0);
No, you need to save return value to variable of type HINSTANCE and then compare it to each of the different error codes prsented in article to know what exactly happened.
HINSTANCE result = ShellExecute(/*...*/);
switch(result) {
case 0: std::cout << "The operating system is out of memory or resources\n"; break;
case ERROR_FILE_NOT_FOUND: std::cout << "The specified file was not found\n"; break;
case ERROR_PATH_NOT_FOUND : std::cout << "The specified path was not found\n"; break;
//...
//etc
//...
default:
if(result <= 32)
std::cout << "Unknown error\n";
else
std::cout << "Everything OK\n";
}
To find out what is the problem with your setup.
Your code is correct. It should work, if all files are really there and your PC is configured properly.
If something is not working, you need to find a cause.