
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thanks Cody and Mattias:
What I did was roll my own compare class that called the StrCmpLogicalW
function. Unfortunately this limits my users to XP only since it's not
available on 2000.
I need to check for string nulls but below is a code fragment to sort file
names as in the XP File Explorer:
Declare Unicode Function StrLogicalComparer Lib "shlwapi.dll" _
Alias "StrCmpLogicalW" (ByVal str1 As String, ByVal str2 As String) As
Integer
Public Class StrLogicalComparerClass
Implements IComparer
Function Compare(ByVal x As [Object], ByVal y As [Object]) As
Integer _
Implements IComparer.Compare
Dim text1, text2 As String
text1 = CStr(x)
text2 = CStr(y)
Return StrLogicalComparer(text1, text2)
End Function 'IComparer.Compare
End Class 'StrLogicalComparerClass
> >What I’m looking for is the class/api that performs the same sort by name as
> >in the XP File Explorer.
[quoted text clipped - 4 lines]
>
> Mattias
Jeremy Chapman - 31 Aug 2005 00:03 GMT
Instead of calling StrLogicalCompare, use your own function:
take the first file name, loop through each character in the file, if it's
numeric append it to one string, otherwise append it to a second string.
convert the first string to an integer. Do the same for the second file
name.
then compare the 2 strings and 2 integers.
> Thanks Cody and Mattias:
> What I did was roll my own compare class that called the StrCmpLogicalW
[quoted text clipped - 29 lines]
>>
>> Mattias