C++: Adding external XML file to a DLL project to load/access it during execution

只谈情不闲聊 提交于 2019-12-24 11:37:28

问题


Is there a way to add files or other binary data to a DLL so that the program can access it during runtime by "loading" with a filename?

I am programming a DLL which has some code fragments like:

SomeObject mObject = SomeObject("filename.xml");

Now I have 2 problems:

  1. I don't know where the .xml file is placed during runtime since I don't know where the DLL is used.
  2. I don't even want to give the .xml file to the user of the DLL.

where SomeObject is from an external library so I can't change the way those objects are created. Some kind of data is needed that can be accessed like a file called "filename.xml".

So how can I "include" the xml file in that DLL?

I'm using Visual Studio 2010 and Visual C++ compiler. I've read some things about "resources" but it looks like I can't acess them like external files (needed for my constructor call) and instead they are kind of imported directly? Maybe I'm wrong there though...

来源:https://stackoverflow.com/questions/25870213/c-adding-external-xml-file-to-a-dll-project-to-load-access-it-during-executio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!