以编程方式更改Windows XP中的默认代码页? (来自德尔福) [英] Programmatically change the default code page in Windows XP? (from Delphi)

查看:171
本文介绍了以编程方式更改Windows XP中的默认代码页? (来自德尔福)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以建议如何以编程方式更改默认的Windows XP代码页(我在Delphi中这样做)? (这相当于进入控制面板 - >区域设置 - >非Unicode应用程序的语言)。



在这种情况下,我要切换到中文(PRC),因此我正在写入以下注册表字符串:
HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\
ACP = 936
MACCP = 10008
OEMCP = 936



(这正是在控制面板中更改非Unicode代码页下拉菜单)。必须有另一个设置,我需要改变 - 我更喜欢使用Win API调用(如果可用),而不是自己写入注册表。



我我也试过设置
HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language\
默认= 0804(中文PRC)无效。



我不想更改'locale'本身,因为这也会改变时间/日期设置,分隔符等。



这是因为我正在使用一个需要渲染汉字的ANSI应用程序,而且我正在编写一个工具来自动切换系统显示的字符(同时保持UI的其他方面)。



谢谢!



Duncan

解决方案

p>唯一适合的时间是,如果您正在编写一个kiosk类型的应用程序,而系统上不会运行任何其他应用程序。该更改将影响系统上的每个其他应用程序。



如果您只需要渲染字符并将其放入WideString,则可以在较旧版本的Delphi通过直接调用Windows API的 W 版本,而不是通过TCanvas方法。也就是说,调用 DrawTextW ExtTextOutW 而不是 TCanvas.TextOut 它将绘制Unicode字符而不将它们转换为系统的ANSI代码页。



更完整的选项是 TMS Unicode组件包。它支持在Delphi 6-2007中启用支持Unicode的应用程序,并为您处理所有的 W 函数。它工作得很好,你可以像常规一样使用TCanvas或Caption / Text属性。唯一的区别是属性都是WideStrings。这是原来的TNT Unicode控件包,并且有一个较旧的,不受支持的版本可用这里



最后,您可以使用Microsoft的 AppLocale 实用程序来更改只有您的应用程序的ANSI代码页。有一个细节从批处理脚本这里调用它,运行它的补丁没有nag屏幕 here ,以及一个名为 SBAppLocale 。它有效,但这是一个黑客,其他选项是长期的。


Could anyone advise how to programmatically change the default Windows XP code page (I'm doing this from Delphi)? (This would be the equivalent of going into Control Panel -> Regional Settings -> Language for non-Unicode applications).

In this case, I want to switch to Chinese (PRC) and so am writing to the following registry strings: HKLM\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ ACP=936 MACCP=10008 OEMCP=936

(Which is exactly what changing the non-Unicode codepage drop down in Control Panel does). There must be another setting which I need to change - and I'd prefer to use a Win API call (if available) rather than writing to the registry myself.

I've also tried setting HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language\ Default=0804 (Chinese PRC) to no avail.

I don't want to change the 'locale' per se as this will also change time / date settings, separators, etc. etc.

This is because I'm using an ANSI application that needs to render Chinese characters, and I'm writing a tool to automatically switch the system show the characters (while leaving other aspects of the UI intact).

Thanks!

Duncan

解决方案

The only time this would be appropriate is if you're writing a kiosk type application where nothing else will run on the system. That change will affect every other application on the system.

If you just need to render the characters and can get them into a WideString you can render them in older versions of Delphi by calling the W versions of the Windows APIs directly, rather than going through the TCanvas methods. That is, call DrawTextW or ExtTextOutW instead of TCanvas.TextOut and it will draw the Unicode characters without converting them to the system's ANSI codepage.

A more complete option is the TMS Unicode Component Pack. It supports making Unicode-enabled applications in Delphi 6-2007, and handles calling all of the W functions for you. It works well, and you can just use TCanvas or the Caption/Text properties like normal.; the only difference is the properties are all WideStrings instead. That was originally the TNT Unicode Controls pack, and there's an older, unsupported version of that available here.

Finally, you can use Microsoft's AppLocale utility to change the ANSI codepage for just your application. There are details on calling it from a batch script here, a patch to run it without the nag screen here, and a command line clone named SBAppLocale. It works, but it's a hack, and the other options are better long-term.

这篇关于以编程方式更改Windows XP中的默认代码页? (来自德尔福)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆