Question

Possible Duplicate:
How to get the sort order in Delphi as in Windows Explorer?

I'm looking for a function that would compare (for file sorting) exactly like Windows Explorer does. Now I'm using CompareText function, but it results in the following:

---------  /\  ---------
 AFile
 BFile
 _XFile
-----------------------

And Windows Explorer sort the same items this way (that's what I want to get):

---------  /\  ---------
 _XFile
 AFile
 BFile
-----------------------

Is there a function for this kind of comparing or should I handle this by my own ?

Thanks!

Was it helpful?

Solution

Windows Explorer uses StrCmpLogicalW to compare file names. The RTL/VCL does not declare this function so you need to do it yourself.

function StrCmpLogicalW(psz1, psz2: PWideChar): Integer; stdcall;
    external 'shlwapi.dll';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top