我需要创建每次插入或拔出 USB 时都会收到通知的应用程序,并且还可以访问它。首先,我尝试使用 USBPrivateDataSample 应用程序作为示例:
http://developer.apple.com/library/mac/#samplecode/USBPrivateDataSample/Listings/USBPrivateDataSample_c.html#//apple_ref/doc/uid/DTS10000456-USBPrivateDataSample_c-DontLinkElementID_4
按顺序为了编译它,我将 SDK 更改为 10.6,因为 Snow 不支持 10.4 豹。
该程序已编译并成功运行,但是,插入 USB 时我没有收到调用/事件。换句话说,函数 DeviceAdded 从未被调用。
这个程序应该可以在 Snow 中运行吗?它看起来很旧,也许有些调用已被弃用?
有人可以建议其他方式来接收 USB 设备通知吗?
谢谢!
I need to create application that get notified each time I plug or unplug USB, and also can get access to it. For start, I tried to use USBPrivateDataSample application as example:
http://developer.apple.com/library/mac/#samplecode/USBPrivateDataSample/Listings/USBPrivateDataSample_c.html#//apple_ref/doc/uid/DTS10000456-USBPrivateDataSample_c-DontLinkElementID_4
In order to compile it I changed SDK to 10.6 since 10.4 is not supported on Snow Leopard.
The program is compiled and runs successfully, however, I do not receive calls/events when the USB is plugged in. In other words, function DeviceAdded is never called.
Does this program supposed to work in Snow anyway? It looks old, maybe some calls are deprecated?
Can someone suggest other way to receive USB devices notifications?
Thanks!
发布评论
评论(1)
该示例应在 10.6 上运行,您可能需要通过删除
kUSBProductID
和kUSBVendorID
匹配字典条目来修改匹配字典以匹配所有设备,或者将它们设置为匹配您的设备,您还可以使用不同的匹配标准(请参阅 qa1076 对于那些)。The sample should work on 10.6, You may need to modify the matching dictionary to either match all devices by removing the
kUSBProductID
andkUSBVendorID
matching dictionary entries, or set these to match your device, you can also use different matching criteria (see qa1076 for those).