在Windows .rc文件/ dll中使用字符串类型的资源标识符 [英] Using string-type resource identifiers in Windows .rc files / dlls

查看:149
本文介绍了在Windows .rc文件/ dll中使用字符串类型的资源标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在我们的代码库中有一些MFC扩展DLL,其中许多已经在项目的.rc文件(IDS _...,IDD _...,IDB _...等)中定义了嵌入式Windows资源。我们使用数字标识符来定义我们的资源,特别注意我们的资源ID不会与dll相冲突,这需要一些管理来确保我们的开发人员不要使用相同的编号。



我意识到字符串类型资源标识符可能是一个简单的方法,这意味着我们可以为每个不同的dll中的每个资源定义唯一的标识符



我的问题是,是否有任何技术问题,例如:




  • MFC DLL /资源链是否仍然正常运行?

  • Visual Studio资源编辑器是否仍然可以正常工作?



我在MS技术说明中没有发现任何问题,说这是一个问题 - 我只是想知道人们是否有经验。

解决方案

请注意,字符串表(IDS_)中的字符串ID必须是数字(16位I IRC)。字符串和另一资源之间的区别是由于字符串不是单个资源。实际上,字符串表由一组资源组成,每个资源最多包含16个具有连续ID的字符串。



对话框中的控件ID也是一样。但是您最有可能知道这一点。



在资源编辑器中,您可以通过简单地在资源名称周围放置引号来指定属性网格中的字符串资源ID。 >

关于对话框和资源编辑器:您将会有一个小问题:无论何时创建对话框的类,生成的代码都包含枚举{IDD = resourceid}。不用说,它不适用于字符串ID。但是您可以轻松地摆脱这个IDD枚举,并用字符串替换它。


We have a number of MFC extension dlls in our code base, many of which have embedded Windows resources defined in the projects .rc files (IDS_..., IDD_..., IDB_... etc). We use numerical identifiers to define our resources, taking special care that our resource ids don't clash across dlls, which requires some management to ensure our developers don't use the same numberings.

I've realised that string-type resource identifiers might be an easy way to go, meaning that we can define unique identifiers for each resource in each different dll.

My question is, are there any technical problems with doing this, for example:

  • Will the MFC dll / resource chain still function correctly?
  • Will the Visual Studio resource editor still work?

I haven't found anything in the MS Technical Notes to say this would be a problem - I'd just wondering if people have had experience with this.

解决方案

Note however that IDs of strings in the string table (IDS_) MUST be numeric (16 bits IIRC). The difference between a string and another resource is due to strings not being individual resources. Actually, the string table consists in a set of resources, each containing up to 16 strings with consecutive IDs.

Same goes for Control IDs within dialogs. But you most likely know that.

In the resource editor, you can specify a string resource id in the property grid by simply putting quotes around the resource names.

Regarding dialogs and the resource editor: You'll have a minor problem: Whenever you create a class for the dialog, the generated code contains enum { IDD = resourceid }. Needless to say that it won't work for a string id. But you can easily get rid of this IDD enum and replace it by a string.

这篇关于在Windows .rc文件/ dll中使用字符串类型的资源标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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