Jump to content

Windows explorer


SASL
 Share

Recommended Posts

Hi,

How can i identify the first file displayed in a folder after sorting? The function FileFindFirstFile returns invariably the first alphabetically sorted file and not the first displayed!

Edited by SASL
Link to comment
Share on other sites

  • Moderators

Why not show us your code and how you're sorting things? My crystal ball is in the shop ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

FileFindFirstFile does not involve or interact with Windows Explorer.  Sorting a Windows Explorer folder is independent from the FileFindFirstFile function, which instead looks at the file system directly.

Also, per Microsoft Documentation for the API,  "The order in which the search returns the files, such as alphabetical order, is not guaranteed, and is dependent on the file system. If the data must be sorted, the application must do the ordering after obtaining all the results.

The order in which this function returns the file names is dependent on the file system type. With the NTFS file system and CDFS file systems, the names are usually returned in alphabetical order. With FAT file systems, the names are usually returned in the order the files were written to the disk, which may or may not be in alphabetical order. However, as stated previously, these behaviors are not guaranteed."

If you want to retrieve the contents of a currently opened Windows Explorer view, you will need to use other methods. 

If you want to use FileFind(First/Next)File functions, you will need to collect all the files (and attributes) that you want to filter for and then sort it using an array for example.

Link to comment
Share on other sites

Excellent explanation, dear Spudw2k.

"If you want to retrieve the contents of a currently opened Windows Explorer view, you will need to use other methods."

So, I need please one of these other methods. Cause making an Array or FileFindFirstFile do not show files in the order they are displayed after sorting.

Link to comment
Share on other sites

I used to be able to interact with the SysListView32 control in windows explorer to retrieve the contents, but (I think since Vista+) I can't any longer.  I think there may still be a way to retrieve it, but I don't have a working example right now.  

This thread may point in the right direction.

 

 

Edited by spudw2k
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...