从初始化程序中中止共享库的加载
我有一个共享库,它在其初始化程序中设置共享内存。 当我无法分配共享内存时,我想中止调用程序对该库的加载,以便该程序的加载失败并可以采取相应的行动。
我正在使用 QLibrary.isloaded() 来检查库是否已加载到调用程序中。
当初始化程序发生错误时,如何防止加载库?
I have a shared library that sets up shared memory in its initializer.
When I can't allocate the shared memory, I would like to abort the loading of this library by the calling program, so that this program's load will fail and can act accordingly.
I am using QLibrary.isloaded() to check if the library is loaded in the calling program.
How can I prevent the library from being loaded when an error in the initializer occurs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
既然你提到了Qt,也许使用 QPluginLoader 更好。阅读有关 Qt 插件 的更多信息,并使您的插件返回指向 QObject 的指针,如果为 NULL 则表示失败。
Since you mention Qt, perhaps using QPluginLoader is better. Read more about Qt Plugins and make your plugin return a pointer to a QObject, which would be NULL to indicate failure.