File Openings

Pages: 123
DOes it opens empty fule when you run this program?
Well I have only run this program at school, with the correct directory path changed, since i cant run this at home atm
Ok, so I just tested it and it DOES NOT work... please help!
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
i dont know what the return value is
So... check it. You need to find out what is gone wrong.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
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);
Ok, well I think I need to use this: _In_ LPCTSTR lpFile, but I dont know how or what the syntax is?!
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.
How do I do that?! That articile was wicked confusing!?
Also can you please check this out? http://www.cplusplus.com/forum/general/152784/
http://www.cplusplus.com/doc/tutorial/functions/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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";
}
Ok, but whats the point of using these errors?
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.
Topic archived. No new replies allowed.
Pages: 123