Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

ToUnicodeEx (user32)
 
.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern int ToUnicodeEx(uint wVirtKey, uint wScanCode, byte []
   lpKeyState, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszBuff,
   int cchBuff, uint wFlags, IntPtr dwhkl);

User-Defined Types:

None.

Notes:

Convert a ASCI Character into Unicode Character with the Keyboard Layout

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

protected override void OnKeyDown(KeyEventArgs e)

{

      System.Text.StringBuilder   sbString        = new System.Text.StringBuilder();

      uint KeyValue     = (uint)e.KeyValue;
      byte[]  bKeyState    = new byte[255];
      bool bKeyStateStatus    = GetKeyboardState(bKeyState); //FIND DECLARATION SIGNATURE OF THIS WINAPI in PINVOKE.NET
      uint  lScanCode    = MapVirtualKey(KeyValue,0);   //FIND DECLARATION SIGNATURE OF THIS WINAPI in PINVOKE.NET
      IntPtr HKL        = GetKeyboardLayout(0);        //FIND DECLARATION SIGNATURE OF THIS WINAPI in PINVOKE.NET
      lReturn        = ToUnicodeEx(KeyValue,lScanCode,bKeyState,sbString,5,0,HKL); // The converted string will be in the                                          sbString.

}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
ToUnicodeEx on MSDN

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 PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions