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
GetStringType (kernel32)
The GetStringTypeEx API returns character information for the characters in the specified string pointer. Three types of character information can be retrieved, depending on the dwInfoType parameter.

C# Signature:

static extern bool GetStringTypeEx(uint Locale, uint dwInfoType,
   [MarshalAs(UnmanagedType.LPWStr)]String lpSrcStr, int cchSrc, [Out] ushort [] lpCharType);

VB Signature:

Private Declare Unicode Function GetStringTypeEx Lib "kernel32" Alias "GetStringTypeExW" ( _
  ByVal Locale As Int32, ByVal dwInfoType As Int32, _
  ByVal lpSrcStr As String, ByVal cchSrc As Int32, _
  ByRef lpCharType As Int16) As Boolean

User-Defined Types:




Tips & Tricks:

Please add some!

Sample Code:

Public Const CT_TYPE1 As Int32 = &H1    ' Retrieves character type info
Public Const CT_TYPE2 As Int32 = &H2    ' Retrieves bi-directional layout info
Public Const CT_TYPE3 As Int32 = &H4    ' Retrieves text processing info

Public Enum CharTypeInfo As Integer
    AnsiPosix = CT_TYPE1
    BidirectionalLayout = CT_TYPE2
    TextProcessing = CT_TYPE3
End Enum

Public Function GetStringTypeEx(ByVal str As String, ByVal cti As CharTypeInfo) As Int16()

    Dim APIRetVal As Boolean
     Dim CharTypeInfoArray(Len(str) - 1) As Int16

     ' No need to specify the Locale, the Unicode (W) version of GetStringTypeEx ignores it anyway
     APIRetVal = GetStringTypeEx(0, cti, str, Len(str), CharTypeInfoArray(0))

     If (Not APIRetVal) Then
             Throw New ApplicationException("GetStringTypeExError")
     End If

     Return CharTypeInfoArray

End Function

Alternative Managed API:

Do you know one? Please contribute it!


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