检查更新
我正在 Lazarus 中开发一个应用程序,需要检查每个 Form_Create
上是否有新版本的 XML 文件。
我该怎么做?
I'm developing a application in Lazarus, that need to check if there is a new version of a XML file on every Form_Create
.
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我过去曾使用 synapse 库来进行此类处理。基本上在 use 子句中包含
httpsend
,然后调用httpgetbinary(url,xmlstream)
来检索包含资源的流。不过,我不会在 OnCreate 中执行此操作,因为提取资源可能需要一些时间。您最好将其放在另一个线程中,该线程可以对表单进行同步回调以启用更新,或设置应用程序标志。这类似于 Chrome 浏览器在“关于”页面上显示更新的方式,当显示表单时启动一个线程来检查是否有更新,当线程完成时它会更新 GUI...这允许其他任务发生(例如小动画,或用户关闭对话框的能力)。Synapse 不是一个可视化组件库,它是一个包含大多数常见互联网协议的阻塞函数库。
I have used the synapse library in the past to do this kind of processing. Basically include
httpsend
in your uses clause, and then callhttpgetbinary(url,xmlstream)
to retrieve a stream containing the resource. I wouldn't do this in the OnCreate though, since it can take some time to pull the resource. Your better served by placing this in another thread that can make a synchronize call back to the form to enable updates, or set an application flag. This is similar to how the Chrome browser displays updates on the about page, a thread is launched when the form is displayed to check to see if there are updates, and when the thread completes it updates the GUI...this allows other tasks to occur (such as a small animation, or the ability for the user to close the dialog).Synapse is not a visual component library, it is a library of blocking functions that wrap around most of the common internet protocols.
您需要阅读FPC 网络、lNet 看起来对于这项任务特别有用。
You'll need to read up on FPC Networking, lNet looks especially useful for this task.