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

getcpinfoex (kernel32)
 
.
Summary

C# Signature:

    /// <summary>
    /// Gets information on a named code page.
    /// </summary>
    /// <param name="CodePage">The code page number.</param>
    /// <param name="dwFlags">Reserved.  Must be 0.</param>
    /// <param name="lpCPInfoEx">The CPINFOEX struct to initialize.</param>
    /// <returns><c>true</c> if the operation completed successfully; <c>false</c> otherwise.</returns>
    [DllImport("kernel32.dll", SetLastError = true)]
    private static extern bool GetCPInfoEx([MarshalAs(UnmanagedType.U4)] int CodePage, [MarshalAs(UnmanagedType.U4)] int dwFlags, out CPINFOEX lpCPInfoEx);

User-Defined Types:

    private const int MAX_DEFAULTCHAR = 2;
    private const int MAX_LEADBYTES = 12;
    private const int MAX_PATH = 260;

    [StructLayout(LayoutKind.Sequential)]
    private struct CPINFOEX
    {
        [MarshalAs(UnmanagedType.U4)]
        public int MaxCharSize;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_DEFAULTCHAR)]
        public byte[] DefaultChar;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_LEADBYTES)]
        public byte[] LeadBytes;

        public char UnicodeDefaultChar;

        [MarshalAs(UnmanagedType.U4)]
        public int CodePage;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
        public string CodePageName;
    }

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    private enum ActCodePage
    {
        CP_ACP = 0,
        CP_OEMCP = 1,
        CP_MACCP = 2,
    }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
GetCPInfoEx 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
Edit This Page
Find References
Show Printable Version
Revisions