GetOpenFileName in Windows 7

Well, I am trying to open a file in Windows 7 by using this shit: GetOpenFileName() and the application crashes when the class of the initial windows is being created. It is said that GetOpenFileName is not recommended to be used in Windows 7. Do you know an alternative for this function so I can open an Save or Open dialog? Thanks!
What is the "initial windows"? What is the "class" of the said "initial windows"? Have you debugged the application? If yes, what function call is making the application crash?

You can find the replacement for this function for Windows 7 if you put some faith in Google: http://bit.ly/zKqlFu .
Well, I can't use IFileDialog because I can't include Shobjidl.h because I am using Code::Blocks because...Fuck this shit!
So, I give up with Code::Blocks. I'm starting with Microsoft Visual Studio 2010. For the moment I see advantages when creating application for Windows. Now I am asking myself what will happen when trying to make them for Linux, MAc or another O.S.?
There is nothing wrong with GetOpenFileName in windows 7, at least not in my applications.

It is certainly a problem with your code.
Now I am asking myself what will happen when trying to make them for Linux, MAc or another O.S.?

What's supposed to happen? WinAPI functions like GetOpenFileName are not available in other operating systems, so you have to use a different API. If you want your program to be portable, use Qt.
Qt means dynamic libraries wherever the executable or static libraries? Well, I better check their page. Thanks!
@modoran yes. It was something else.
I use the GetOpenFileNameA and GetSaveFileNameA functions from comdlg32.dll. I often set the initial directory to the user's My Documents folder (using calls to SHGetSpecialFolderLocation and SHGetPathFromIDListA from shell32). This all works fine under Windows XP.

However, I recently switched to Windows 7 as my development environment and have been getting the following error message:You can’t open this location using this program. Please try a different location.


In many of my Access (2002) programs I use the GetOpenFileNameA and GetSaveFileNameA functions from comdlg32.dll. I often set the initial directory to the user's My Documents folder (using calls to SHGetSpecialFolderLocation and SHGetPathFromIDListA from shell32). This all works fine under Windows XP.

However, I recently switched to Windows 7 as my development environment and have been getting the following error message:

You can’t open this location using this program. Please try a different location.

The function I use to get the My Documents location is returning the correct folder. However, even if I hard code that directory location into the GetOpenFileNameA call, I still get the error.

I came across this post: http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/3391f1dd-25b0-4102-9d5c-58309cc72c9d but, even adapting it to work with Access instead of Excel, I had no luck.


You could write an c++ dll which return the files selected for you as a out of process COM server and it must work.
Maybe Access 2002 is somehow blacklisted (I've seen drivers blacklisted in win7 which works in vista)
Windows 7 has some security features that blocks programs from managing some stuff (almost all) from the partition where the O.S. is installed. I think that only the Users/Public folder is permitted to be accessed, modified, etc. That may be the reason for which there are problems with opening directories with GetOpenFileNameA/GetSaveFileNameA. Try to open a file from D: (or anything else than the Windows partition) and see what happens.
In a future, when I am gonna learn how to create an installer for my application I will need some information about how to grant rights to it and avoid this kind of problems in Windows 7
Topic archived. No new replies allowed.