Opening files in windows 7&8

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Opening files in windows 7&8

Post by Kempelen »

Hello,

After I upgraded my development machine and test machine to windows 7 and 8, my programs open a window (cancel, retry or ignore) when a file or disk is not found:

FILE *fOut = fopen(.......
if (fOut == NULL) {
....
}

It looks that Windows pops up the retry windows before the 'if' command, and this is very annoiyed. Is there any way to say windows to work as it did in previous versions? are more people having this problem or am I the only rare person having this issue?

P.S.: It happens to me also that signal() is not cathing crashes as in windows XP or Vista, now a window appear to notify the user about it. My signal-dedicated function does not work any longer. the same to you?
Thanks.
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Opening files in windows 7&8

Post by tpetzke »

Hi Fermin,

I'm using this little helper function. This works both in XP and Win7.

Code: Select all

bool fileExists(string filename)
{
    ifstream ifile(filename.c_str());
    return (ifile != NULL);
}
Thomas...
User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: Opening files in windows 7&8

Post by Kempelen »

tpetzke wrote:Hi Fermin,

I'm using this little helper function. This works both in XP and Win7.

Code: Select all

bool fileExists(string filename)
{
    ifstream ifile(filename.c_str());
    return (ifile != NULL);
}
Thomas...
This look like a C++ function which it is not in pure C. :(
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Opening files in windows 7&8

Post by Sven »

Does it depend on the folder where you want to open a file?
Does it also happen if you provide the absolute path to the file?
Could it be a permission problem?
Win7 (like Vista) has UAC = User Access Control, which is one of the most annoying things I have ever seen. It can be disabled via Control Panel.

Sven
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: Opening files in windows 7&8

Post by rvida »

Kempelen wrote:Hello,

After I upgraded my development machine and test machine to windows 7 and 8, my programs open a window (cancel, retry or ignore) when a file or disk is not found:

FILE *fOut = fopen(.......
if (fOut == NULL) {
....
}

It looks that Windows pops up the retry windows before the 'if' command, and this is very annoiyed. Is there any way to say windows to work as it did in previous versions?
Have you tried SetErrorMode(SEM_FAILCRITICALERRORS)?

From MSDN:
SEM_FAILCRITICALERRORS:
The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application.
User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: Opening files in windows 7&8

Post by Kempelen »

rvida wrote:
Kempelen wrote:Hello,

After I upgraded my development machine and test machine to windows 7 and 8, my programs open a window (cancel, retry or ignore) when a file or disk is not found:

FILE *fOut = fopen(.......
if (fOut == NULL) {
....
}

It looks that Windows pops up the retry windows before the 'if' command, and this is very annoiyed. Is there any way to say windows to work as it did in previous versions?
Have you tried SetErrorMode(SEM_FAILCRITICALERRORS)?

From MSDN:
SEM_FAILCRITICALERRORS:
The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application.
Thanks this is the solution. I also solves signal catching.
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/