winapi – 如何以编程方式确定Windows的当前默认代码页?

我必须将VB6应用程序的字符串输出的编码转换为特定的编码.

问题是,我不知道字符串的编码,因为:

According to the VB6 documentation when accessing certain API functions the internal Unicode strings are converted to ANSI strings using the default codepage of Windows.

因此,字符串输出的编码在不同系统上可能不同,但我必须知道它才能执行转换.

如何使用Win32 API读取代码页,或者 – 如果没有其他方法 – 通过阅读注册表?

通过使用 GetACP – Win32 API调用返回代码页,它可能更简洁! (代码页通常称为“ANSI”)
int nCodePage = GetACP();

此外,许多API调用(例如MultiByteToWideChar)接受始终为means “use the system code page”的常量值CP_ACP(零).因此,您可能实际上不需要知道当前代码页,具体取决于您要对其执行的操作.

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...