C ++中的嵌入式资源 [英] Embedded resource in C++

查看:218
本文介绍了C ++中的嵌入式资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建嵌入式资源,然后从C ++访问它?

How do I create an embedded resource and then access it from C++?

任何关于如何读取资源的示例都是很好的。

Any example on how to read the resource would be great.

我使用Visual Studio 2005.

I am using Visual Studio 2005.

提前感谢。

编辑:我想放置一个xsd文件,这是验证接收的xml文件的模式所需的。

I want to put one xsd file which is required while validating schema of the recieved xml file.

推荐答案

@Sharptooth之前解释并使用以下代码获取资源

I'm doing @Sharptooth explained before and use the following code to get the resource

HRSRC hResInfo = FindResource(hInstance, MAKEINTRESOURCE(resourceId), type);
HGLOBAL hRes = LoadResource(hInstance, hResInfo);
LPVOID memRes = LockResource(hRes);
DWORD sizeRes = SizeofResource(hInstance, hResInfo);

您必须更改 resourceId code> type 。

Here you have to change resourceId and type.

例如对于.png文件,我使用 FindResource(hInstance,MAKEINTRESOURCE(bitmapId),_T(PNG)); (PNG字符串是您添加自定义资源时使用的类型)。

For example for a .png file I use FindResource(hInstance, MAKEINTRESOURCE(bitmapId), _T("PNG")); (the "PNG" string is the type you used when adding a custom resource).

这篇关于C ++中的嵌入式资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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