3

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!

Community
  • 1
  • 1
Martin Reiner
  • 2,167
  • 2
  • 20
  • 34

1 Answers1

7

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';
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490