在本地存储变量
有没有办法可以在本地存储号码?
我想制作一个计数器,因此每次用户单击按钮时,数字都会增加。但我希望将其存储起来,以便我可以重新启动计算机,并在加载时显示最后一个数字。
Is there a way i can store a number locally?
I want to make a counter, so each time the user clicks the button the number is increased. But i would like it to be stored so i could reboot my computer and when its loaded it displays the last number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会参考这个网站: http://dotnetslackers.com/articles/net/SettingsManagerforWindowsVistaSidebarGadgets.aspx< /a>
您可以下载并实现它,尽管它对于您所需的功能来说有点庞大。或者,您可以下载它并查看 SettingsManager.js 文件如何创建一个 .ini 文件,然后从中读取(然后您可以使用该文件创建一个包含整数的 .ini 文件,您每次需要加载时都会读取该文件)值并在每次值更改时保存)。
I would refer to this website: http://dotnetslackers.com/articles/net/SettingsManagerforWindowsVistaSidebarGadgets.aspx
You can either download and implement that, though it's a bit bulky for your desired functionality. Alternatively, you can download it and see how the SettingsManager.js file creates an .ini file and then later reads from it (which you could then use to make an .ini file holding an integer, which you would read every time you wanted load the value and save every time the value changed).
为此,您可以做得比使用 Windows 注册表更糟糕。
使用 C++ 的一些信息
< a href="http://www.csharphelp.com/2007/01/registry-ins-and-outs-using-c/" rel="nofollow">使用 C# 的一些信息
You could do worse than use the Windows Registry for this.
Some information using C++
Some information using C#