以编程方式修改库 [英] Modifying Library Programmatically

查看:70
本文介绍了以编程方式修改库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写的简单程序包含列出城市名称的数组,只打印它们。



我创建了一个dll库。



现在我可以通过其他C程序在库中修改数组(以添加更多城市名称)吗?

解决方案

< blockquote>另一种可能性是让你的dll搜索包含你的可编辑列表的文件的存在,如果找到,加载它。如果它不在那里,那么你可以默认使用硬编码到你的dll中的列表。这样,您可以通过将城市附加到您的文件来添加城市,而无需在每次要添加城市时重新创建dll。


创建一个将数据作为 STL list [< a href =http://msdn.microsoft.com/en-us/library/802d66bt(VS.80).aspx\"target =_ blanktitle =New Window> ^ ]。然后你的代码可以添加到列表本身,或者在DLL中添加另一个方法来添加项目。但是,请记住,额外的项目不会保留在DLL中。如果您希望永久更新列表,那么从源代码重建将更加容易。


I have written simple program consisting of an array listing names of cities and just printing them.

I have created a dll library of it.

Now can I modify the array( to add some more names of cities ) in library through some other C program?

解决方案

Another possibility would be to have your dll search for the presence of a file that contains your editable list, and if found, load that up. If it''s not there, then you could default to the list you have hardcoded into your dll. That way, you can add cities by appending them to your file without having to recreate the dll each time you want to add a city.


Create a method that returns the data as a STL list[^]. Then your code can either add to the list itself, or have another method in the DLL that will add items to it. However, remember that the extra items will not be persisted inside the DLL. If you want the list to be updated permanently then it would be much easier to rebuild from the source.


这篇关于以编程方式修改库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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