Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How How to install the Notification for Device On or Off

How How to install the Notification for Device On or Off
Thread Tools
yesea
Fresh-Faced Recruit
Join Date: Oct 2004
Status: Offline
Reply With Quote
Mar 29, 2005, 10:28 PM
 
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 ( );
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:18 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,