Symbian C++ - 单个变量的持久存储
我希望在我的应用程序中存储一个变量,该变量将在运行之间保存。 这将是用于触发更新选项的版本号,因此很少会更改。
有人对实现这一点的最佳方法有建议吗? 考虑到这是一个如此简单的要求,我对最简单的解决方案感兴趣。
谢谢!
I wish to store a single variable in my application that will be saved between runs. This will be a version number that will be used to trigger an update option and so will change only rarely.
Does anyone have suggestions on the best way of implementing this? Considering it's such a simple requirement I am interested in the simplest solution.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,此类信息将保存在二进制文件中的常量(而不是变量)中,并且二进制文件将联系外部站点以查明是否有该软件的更新版本。 当它下载新的时,新下载的文件将嵌入一个新的常量。
或者,您可以将信息保存在文件系统中的某种文件中。 我不熟悉 Symbian 环境,但很可能存在类似的环境。
Normally, that sort of information will be held in a constant (not a variable) in the binary, and the binary will contact an external site to find out whether there is a more recent version of the software. When it downloads the new, the newly downloaded file will have a new constant embedded in it.
Alternatively, you could keep the information in some sort of file in the file system. I'm not familiar with the Symbian environment, but something similar most likely exists.
前面已经提到了,所以我再详细说明一下。 在项目目录中创建一个包含版本号的文件。 通过在 PKG 文件中添加一行相关内容,使该文件成为最终 SIS 文件的一部分 — 例如,在 PKG 文件中添加一行,告诉安装程序将该文件复制到
c:\ 等位置设备上的 System\Apps\${AppName}\${filename}
。 在代码中,从该文件中读取版本号。 这样做的好处是,当您更新代码并编辑项目目录中的文件并重新创建更新的 SIS 文件时,在更新设备上的 SIS 时,版本文件将自动替换为当前版本一。It has already been mentioned, so I am going to elaborate on it. Create a file in your project directory that will contain the version number. Make that file a part of final SIS file by adding a line about it in the PKG file---for example, put a line in the PKG file to tell the installer to copy the file to a place like
c:\System\Apps\${AppName}\${filename}
on the device. Within code, read the version number from that file. The advantage you will have from doing it this way is that when you update your code and edit the file in your project directory and recreate an updated SIS file, on updating the SIS on the device, the version file will automatically get replaced with the current one.