Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:11:09+00:00 2026-06-14T14:11:09+00:00

I know that Microsoft recommends using the Common Item Dialog boxes over GetOpenFileName() and

  • 0

I know that Microsoft recommends using the Common Item Dialog boxes over GetOpenFileName() and GetSaveFileName() but I am working with some older code.

How can I limit GetOpenFileName() to only allow the user to select files in a certain directory?

For example, I only want the user to be able to select a file from the “Images” directory. I don’t want them to be able to navigate into other directories when opening a file. They must select a file from the “Images” directory.

The flag OFN_NOCHANGEDIR sounds like it could be what I need, but that just changes the current directory back to the original directory if the user changes it when opening a file.

If it’s not possible with GetOpenFileName(), is it possible with the newer Common Item Dialog?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:11:11+00:00Added an answer on June 14, 2026 at 2:11 pm

    For GetOpenFileName() and GetSaveFileName(), you can assign a callback procedure to the OPENFILENAME::lpfnHook field. When it receives a CDN_FILEOK notification, retrieve the selected folder by sending the dialog a CDM_GETFOLDERPATH message. If the folder is not acceptable to you, display a message to the user and then reject the selected file(s) by calling SetWindowLong() to set a nonzero DWL_MSGRESULT value, and return a nonzero value from the hook procedure.

    Update: for IFileOpenDialog and IFileSaveDialog, you can implement the IFileDialogEvents::OnFolderChanging event callback to prevent navigation to unwanted folders, by simply returning an error HRESULT value other than S_OK or E_NOTIMPL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that Windows certificate Store exist in registry at SystemCertificates key (\SOFTWARE\Microsoft\SystemCertificates). But
I know that SSRS 2008 rdl schema is located at http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition but what is
I know that the reason that Microsoft came out with ASP.NET MVC was to
I have an application that requires Microsoft VC++ 2005 (SP1) Redistributable Package. I know
I know that Phonegap has an event for back button, but it's only available
I know that this sort of question has been asked here before, but still
I know that Java have its own garbage collection, but sometimes I want to
I know that the Microsoft SOAP toolkit has been deprecated for a while now
While looking at Microsoft's web site, I discovered that they no longer recommend using
I want to get started doing some game development using Microsoft's XNA. Part of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.