File Openings

Pages: 123
Jan 29, 2015 at 8:30pm
DOes it opens empty fule when you run this program?
Jan 29, 2015 at 8:44pm
Well I have only run this program at school, with the correct directory path changed, since i cant run this at home atm
Jan 30, 2015 at 6:53pm
Ok, so I just tested it and it DOES NOT work... please help!
Jan 30, 2015 at 8:03pm
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?
Jan 31, 2015 at 5:37pm
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
Jan 31, 2015 at 6:32pm
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);
Jan 31, 2015 at 6:40pm
Ok, well I think I need to use this: _In_ LPCTSTR lpFile, but I dont know how or what the syntax is?!
Jan 31, 2015 at 6:46pm
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.
Jan 31, 2015 at 6:56pm
How do I do that?! That articile was wicked confusing!?
Jan 31, 2015 at 6:59pm
Also can you please check this out? http://www.cplusplus.com/forum/general/152784/
Jan 31, 2015 at 7:04pm
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";
}
Jan 31, 2015 at 7:09pm
Ok, but whats the point of using these errors?
Jan 31, 2015 at 7:14pm
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