Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFileDialog Access is denied in Windows 2000

Status
Not open for further replies.

Frink

Programmer
Mar 16, 2001
798
GB
Hallo,

I have written some code using Visual C++ 6.0 Enterprise edition, running on Windows NT 4.
This code uses the CFileDialog to allow the user to select one or more files to import.
It works fine on the NT box, either as a debug version or as Release. However, I get errors when running the executable on a Windows 2000 box, but only in the Release build.
On W2k the debug build works fine. The release version gives an 'Access is denied' error and does not import the files.

Any clues?

Thanks,

-Frink
 
it just means you do not have right to access that directory. Choose another directory, or update right access to that directory.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Hallo,

Cheers.
It could have been that, but I don't think it is. If I run the Debug version in parallel with the Release version, the Debug one works, the Release doesn't. And that's both using the same files/directories.

The Release build works fine if I disable optimisation in the configuration.

- Frink
 
What do you think 'Access is denied' is about? This also could mean what you're accessing some inaccessible part of memory, or some inaccessible directories in the background.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Hallo,

I found something on the web (I think it was but that's inaccessible at the moment) which indicated that the OPENFILENAME struct is different for Windows 2000.

I think that maybe the optimised code somehow 'unmasks' an error lurking, but not visible in the unoptimised version. I'm guessing that this causes the 'Access is Denied' error, rather than it actually being a file sharing problem (I've also tried the OFN_SHAREAWARE option every-which way to no avail)

Anyway, I shall probably stick with the un-optimised version for the moment and see how it goes.

- Frink
 
I think this could happen because the MFC dlls that you app access and on which your exe was build on NT 4 are not the same on the W2k machine. If it is the case you have the deploy your appplication with the dlls that it was build.
-obislavu-


 
Hallo,

Cheers obislavu, have you any idea which DLL(s) contain the dialog used by CFileDialog? I assume I just have to put them in the same directory as the executable, is that right?

- Pete
 
you should
#define _WIN32_WINNT 0x0500

and the member:
OPENFILENAME::lStructSize
Specifies the length, use sizeof(OPENFILENAME) for this parameter in Windows 2000/XP.


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Hallo,

Cheers IonFilipski, #define _WIN32_WINNT 0x0500 would compile for Windows 2000, but wouldn't that give me unpredictable results running on Windows NT (as the structure sizes are different)

Similarly won't sizeof(OPENFILE) be determined at compile time and therefore be the sizeof(OPENFILE) in the compilation machine, not the target machine.

However I look at it, either the Windows 2000 machine will have to use the Windows NT dialog (if that's possible) or code will have to be written to determine the operating system at run-time and execute separate paths depending on whether it's NT or W2k.
Lots of packages run on either NT or W2k, so it must be possible some how, I just wasn't sure how.

- Frink
 
If you're using 0x0500 for _WIN32_WINNT and compile under NT4x you can use OPENFILENAME_SIZE_VERSION_400 for lStructSize. In this case you should have different programs compilled for different platform.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top