简体   繁体   English

如何在 Visual Studio 中使用 Resource.RC 文件

[英]How to use Resource.RC file in Visual Studio

For context, I have been trying to include 2 PNG files with my C++ code, but I have not been able to figure out how to do so in Visual Studio 2019. I have searched through the docs and have not found anything helpful.对于上下文,我一直试图在我的 C++ 代码中包含 2 个 PNG 文件,但我无法弄清楚如何在 Visual Studio 2019 中这样做。我搜索了文档,但没有找到任何有用的东西。 How could I accomplish the three items listed below?我怎样才能完成下面列出的三个项目?

  1. Correctly include files in a Resource.RC file (and correctly create a Resource.RC file)在 Resource.RC 文件中正确包含文件(并正确创建 Resource.RC 文件)
  2. Access these files in a filesystem-independent manner in C++ (no absolute paths)在 C++ 中以独立于文件系统的方式访问这些文件(无绝对路径)
  3. Include these files when distributing an executable分发可执行文件时包含这些文件

My solution is laid out in the default manner: a References folder, External Dependencies folder, Header Files folder, Resource Files folder, and a Source Files folder.我的解决方案以默认方式布局:References 文件夹、External Dependencies 文件夹、Header Files 文件夹、Resource Files 文件夹和 Source Files 文件夹。

添加 .rc 文件参考微软文档,你可以使用或加载这个 rc 资源参考这个链接,windows api findresource 和 loadresource 可以通过定义资源 ID 来使用这个 rc 文件资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM