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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:10:42+00:00 2026-05-26T07:10:42+00:00

In win32 c++; is there a way to determine if a folder/file is accessible?

  • 0

In win32 c++; is there a way to determine if a folder/file is accessible? You know how if you try to access a certain folder in the C:/Windows directory & you will get a popup saying “This folder is not accessible”.

Maybe there is a file attribute constant that signifies that the file is private? Maybe something like FILE_ATTRIBUTE_PRIVATE?

WIN32_FIND_DATA dirData;

while (FindNextFile( dir, &dirData ) != 0 )
{
    // I made the following constant up
    if ( !(fileData.dwFileAttributes & FILE_ATTRIBUTE_PRIVATE) )
    {
        // file is accessible so store filepath
        files.push_back( fileData.cFileName );
    }
    else // file is not accessible so dont store
}

Or is the only way to know by going:

dir = FindFirstFileEx( (LPCTSTR)directory.c_str(), FindExInfoStandard, &dirData, FindExSearchNameMatch, NULL, 0 );

if ( dir == ??? ) { the file is inaccessible } [/code]
  • 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-26T07:10:43+00:00Added an answer on May 26, 2026 at 7:10 am

    It wouldn’t be a flag on the file itself because different accounts may have access to different files/directories. Instead, windows uses ACL’s (access control lists), which are data structures that determine who has access to what.

    ACLs in windows can be used with just about anything that is referred to by a handle (files, directories, processes, mutexes, named pipes…). You can view file ACLs by going to properties of a file and view “Security” tab.

    So in your app you don’t really want to check for a flag, but to compare file’s ACL against the user account under which your app is running. Check out AccessCheck Win32 function. I think it’s exactly what you are looking for.

    Personally, I’ve never used that function, but if you are looking for Win32 solution and you want a function call, that’s probably your best bet. However, as others have pointed out, it might be too complicated. I’ve always used _access (or _waccess) which is part of CRT, uber easy to use, and you don’t take a performance hit of acquiring a file handle only to close it (depending on how tight your loop is, those calls can actually add up).

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

Sidebar

Related Questions

From the native Win32 API using C++ is there a way to determine whether
Is there any way in Win32 to programmatically determine the bandwidth of a given
Is there any way in a Win32 environment to tune the timeout on a
Is there some way in the Win32 API to convert a three letter language
Is there any way to reliably capture all changes made to the win32 console
In Win32, is there any way to get a unique cpu cycle count or
I'm using Microsoft.Win32.OpenFileDialog dlg in my WPF application. Is there any way to add
Using Win32-specific APIs, is there an easy way to start an external application to
Is there a Win32 equivalent to the linux header file? I'm working on a
Is there a way to call C#/.NET/win32 from HTML5?

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.