您可以访问标准的 Windows 字符串,如“取消"吗? [英] Can you access standard Windows strings like 'Cancel'?

查看:20
本文介绍了您可以访问标准的 Windows 字符串,如“取消"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个具有标准确定"和取消"按钮的 Windows 对话框.鉴于 Windows 在其自己的对话框中使用相同的按钮文本,我有办法获取正确的字符串以在按钮上使用吗?

I am building a Windows dialog box that has the standard 'OK' and 'Cancel' buttons. Given that Windows uses the same button text in its own dialogs is there a way for me to grab the correct strings to use on the buttons?

这样,无论使用哪种语言,我的应用程序都将拥有正确的字符串,而无需我自己将其本地化为许多不同的语言.我正在使用 C#,但如果需要,我可以愉快地使用平台调用来访问操作系统方法.

This way my application will have the correct strings no matter which language is being used, without me needing to localize it for lots of different languages myself. I am using C# but can happily use platform invoke to access an OS method if needed.

注意:是的,我可以轻松地本地化资源,但我不想找到并且必须输入无数不同的语言字符串,因为它必须已经存在于 Windows 中.请不要回答说本地化应用程序!

NOTE: Yes, I can easily localize the resources but I do not want to find and have to enter the zillion different language strings when it must be present within windows already. Please do not answer by saying localize the app!

推荐答案

在 Visual Studio 中:文件 + 打开 + 文件,键入 c:windowssystem32user32.dll.打开字符串表节点并双击字符串表.向下滚动到 800.

In Visual Studio: File + Open + File, type c:windowssystem32user32.dll. Open the String Table node and double click String Table. Scroll down to 800.

Microsoft 对依赖这些资源 ID 采取了非常严肃的立场.考虑到已经完成您正在考虑的事情的程序员的数量,但是他们不太可能改变这些数字.您需要 P/Invoke LoadLibrary() 和 LoadString().

Microsoft takes a pretty no-nonsense stance against relying on these resource IDs. Given the number of programmers who've done what you're contemplating, it is however unlikely they can ever change these numbers. You'll need to P/Invoke LoadLibrary() and LoadString().

但是,您对这个计划的最终失败是带有 MUI 语言包的 Vista/Win7 Ultimate.这允许用户在语言之间切换 更新 DLL 中的资源字符串.这样的版本总是有英文字符串.

However, your ultimate downfall on this plan is Vista/Win7 Ultimate with MUI language packs. Which allows the user to switch between languages without updating the resource strings in the DLLs. Such an edition will always have English strings.

这篇关于您可以访问标准的 Windows 字符串,如“取消"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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