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 7607111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:34:47+00:00 2026-05-31T00:34:47+00:00

I need to retrieve a handle to a directory to be able to call

  • 0

I need to retrieve a handle to a directory to be able to call ReadDirectoryChangesW on it. Actually I would need a bit more than that but let’s go easy first. I have narrowed down the problem to this:

m_directoryHandle = CreateFileA(
    "C:\\Users\\victor\\Documents\\Projets\\libxnotify\\unittests", // __in      LPCTSTR lpFileName,
    FILE_LIST_DIRECTORY,    // __in      DWORD dwDesiredAccess,
    0,                      // __in      DWORD dwShareMode,
    0,                      // __in_opt  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
    OPEN_EXISTING,          // __in      DWORD dwCreationDisposition,
    0,                      // __in      DWORD dwFlagsAndAttributes,
    0                       // __in_opt  HANDLE hTemplateFile
);

This return an INVALID_HANDLE_VALUE with a last error code of ERROR_ACCESS_DENIED. Needless to say, I have tried oodles of different parameters, none on them did work. I run my program as victor, and to make sure I really had the rights in that unittests directory, I opened a command shell and typed:

C:\Users\victor>echo bla >> "C:\Users\victor\Documents\Projets\libxnotify\unittests\test"

and it worked.

  • 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-05-31T00:34:48+00:00Added an answer on May 31, 2026 at 12:34 am

    The documentation for ReadDirectoryChangesW has a remark that states:

    To obtain a handle to a directory, use the CreateFile function with the FILE_FLAG_BACKUP_SEMANTICS flag.

    The documentation for CreateFile then also has a more detailed remark about this:

    Directories

    An application cannot create a directory by using CreateFile, therefore only the OPEN_EXISTING value is valid for dwCreationDisposition for this use case. To create a directory, the application must call CreateDirectory or CreateDirectoryEx.

    To open a directory using CreateFile, specify the FILE_FLAG_BACKUP_SEMANTICS flag as part of dwFlagsAndAttributes. Appropriate security checks still apply when this flag is used without SE_BACKUP_NAME and SE_RESTORE_NAME privileges.

    You’re missing out on this important FILE_FLAG_BACKUP_SEMANTICS flag for dwFlagsAndAttributes.

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

Sidebar

Related Questions

I need to retrieve the date from a UIDatePicker (Preferably I would also like
I need to retrieve the name of the stored procedure that a crystal report
I want to retrieve all the RULE nodes that have one or more attributes
I need to retrieve an array with category names. It seems that tag names
I've created a custom payment gateway but now I need to handle post payment
I need to retrieve all rows from a table where 2 columns combined are
I need to retrieve a record from a database, display it on a web
I need to retrieve a set of Widgets from my data access layer, grouped
I need to retrieve, in my Win32 standalone program, a list of currently installed
I need to retrieve random rows from SQL Server database. I am looking for

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.