Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
CompareString (kernel32)
TODO - a short description

C# Signature:

    [DllImport("kernel32.dll",CharSet=CharSet.Unicode, SetLastError=true)]
    static unsafe extern int CompareStringEx(String strLocale, int flags, String str1, int count1, string str2, int count2, char* version, char* reserved, int param );

VB Signature:

    Public Const LOCALE_NAME_USER_DEFAULT As String = Nothing
    Public Enum EComparationFlags As UInt32
    Zero = &H0
    NORM_IGNORECASE = &H1 'ignore case
    NORM_IGNORENONSPACE = &H2 'ignore nonspacing chars
    NORM_IGNORESYMBOLS = &H4 'ignore symbols
    LINGUISTIC_IGNORECASE = &H10 'linguistically appropriate 'ignore case'
    LINGUISTIC_IGNOREDIACRITIC = &H20 'linguistically appropriate 'ignore nonspace'
    NORM_IGNOREKANATYPE = &H10000 'ignore kanatype
    NORM_IGNOREWIDTH = &H20000 'ignore width
    NORM_LINGUISTIC_CASING = &H8000000 'use linguistic rules for casing
    SORT_STRINGSORT = &H1000 'use string sort method
    SORT_DIGITSASNUMBERS = &H8 'use digits as numbers sort method
    End Enum
    Public Enum EComparationResult As Int32
    CSTR_LESS_THAN = 1 'string 1 less than string 2
    CSTR_EQUAL = 2 'string 1 equal to string 2
    CSTR_GREATER_THAN = 3 'string 1 greater than string 2
    End Enum
    Public Declare Unicode Function CompareStringEx Lib "kernel32" (ByVal strLocaleName As String, ByVal dwComparationFlags As EComparationFlags, ByVal str1 As String, ByVal iLength1 As Int32, ByVal str2 As String, ByVal iLength2 As Int32, ByVal pVersionInformation As IntPtr, ByVal pReserved As IntPtr, ByVal lParam As IntPtr) As EComparationResult

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!

CompareInfo.Compare() functions.



Tips & Tricks:

Please add some!

Sample Code:

Please add some!


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" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version