TODO: someone please check the C# signature and add C# sample code
C# Signature: (TODO)
[DllImport("shlwapi.dll", SetLastError=true)]
static extern int StrCmpLogicalW(String x, String y);
VB Signature:
Declare Unicode Function StrCmpLogicalW Lib "shlwapi.dll" (ByVal s1 As String, ByVal s2 As String) As Int32
User-Defined Types:
None.
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
Comparison is case insensitive, numbers are treated by numerical value instead of ASCII code, for example:
File1
fIle2
fiLe10
instead of
File1
fiLe10
fIle2
Tips & Tricks:
Please add some!
Sample Code:
Private Class StringLogicalComparer
Implements IComparer(Of String)
Private Declare Unicode Function StrCmpLogicalW Lib "shlwapi" _
(ByVal s1 As String, ByVal s2 As String) As Integer
Public Function Compare(ByVal x As String, ByVal y As String) _
As Integer _
Implements System.Collections.Generic.IComparer(Of String).Compare
Return StrCmpLogicalW(x, y)
End Function
End Class
Private Sub Test()
Dim cp As New StringLogicalComparer
Debug.WriteLine(cp.Compare("a", "a")) ' 0
Debug.WriteLine(cp.Compare("1", "1")) ' 0
Debug.WriteLine(cp.Compare("a1", "a2")) ' -1
Debug.WriteLine(cp.Compare("a10", "a2")) ' +1
End Sub
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" in the upper right corner and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).
Profile your .NET code
Boost the performance of your application with ANTS Profiler
This download also contains the FREE PInvoke.net Visual Studio Add-in