Hi All,
I want to add Notification in my code when the Sisc device plug -in or plug-off . eg , plug-in one USB DVD-RW device , i want to get the message when i application running . I have realize some code to do this .But , there are two problem . First , I cann't recevie the device Plug-IN message . Second, When i call the API CFRunLoop() .My application cann't do anthing else except to recevie the message from CallBack Function . anyone have a suggest .Thanks very much ..
My code piece here :
gNotifyPort = IONotificationPortCreate ( kIOMasterPortDefault );
// Add it to the runloop
CFRunLoopAddSource ( CFRunLoopGetCurrent ( ),
IONotificationPortGetRunLoopSource(gNotifyPort ),
kCFRunLoopCommonModes );
// Add matching notifications for optical devices
IOServiceAddMatchingNotification ( gNotifyPort, kIOMatchedNotification, //kIOFirstMatchNotification,
IOServiceMatching ( kIOCDBlockStorageDeviceString ),
&ServiceMatched,
NULL,
&iterator );
// The iterator might have objects here. Clear it out.
ServiceMatched ( NULL, iterator );
// Run the runloop. We should not return from this call until someone quits the app.
CFRunLoopRun ( );