Visual C ++获取资源的路径 [英] Visual C++ Get a resource's path

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

问题描述

我试图添加一个图像到Visual C ++项目,并获得它的路径。
基本上,我想要的是添加一些图像到项目,所以它可以运行在任何计算机上通过获取项目中的必要的图像而不是本地驱动器上。

I'm trying to add an image to Visual C++ project and obtain it's path. Basically what I want is to add a few images to the projects so it can run on any computer by fetching the necessary images inside the project instead that on the local drive.

我通过右键单击资源文件(在解决方案资源管理器菜单中)和add-> existing元素添加了图像。

I added the images by a right click on resources files (in the solution explorer menu) and add->existing element.

但元素仍然具有本地路径(C:/ images /.../ img.jpg)。如何正确添加这些图像到我的项目,并能够获得他们的路径?

But the element still have it's local path (C:/images/.../img.jpg). How can I properly add these images to my project and be able to obtain their paths?

感谢

推荐答案

添加到资源文件的图片将被编译并嵌入到您的代码中而不是程序外的目录中,并且您可以在运行时使用FindResource / LoadResource访问它们。

Images that added to resource file will be compiled and embedded into your code not in a directory outside of your program and you can access them at runtime using FindResource/LoadResource

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

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