挂载磁盘映像时磁盘仲裁的双重回调
我在使用 DiskArbitration 框架时遇到问题,为了捕获磁盘映像安装,我注册了 DARegisterDiskMountApprovalCallback。问题是每次挂载磁盘映像时,都会调用回调两次。这是为什么?我该如何解决这个问题?
I have a problem using DiskArbitration framework, to catch disk image mounting I register for DARegisterDiskMountApprovalCallback
. The problem is that each time a disk image is mounted, the callback is called twice. Why is that and how can I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我最终编写了一些代码来检测第二个安装并忽略它。
I ended up coding something to detect the 2nd mount and ignore it.
挂载磁盘后,您经常会看到整个磁盘的事件,然后是该磁盘上不同分区的事件。你需要区分。
将
CFShow(dict)
放入事件处理程序中并查看会得到什么是非常方便的。When a disk is mounted you often see an event for the whole disk and then events for distinct partitions on that disk. You'll need to distinguish.
It's very handy to put a
CFShow(dict)
in your event handler and see what you get.您是否在回调中放置了断点以查看调用时的调用堆栈是什么?它可以为您提供一些有关正在发生的事情的提示。
Did you put a breakpoint in your callback to see what are the call-stack when it is called ? It can gives you some hints on what is going on.
我用这些来抓住那个。我不确定这些与你正在做的事情有什么区别,但它们有效。
I use these the catch that. I'm not sure of the difference these are to what you're doing but they work.