| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Hi all,
Plz help me.
On Wed, 18 Jan 2006 darpan kamboj wrote :
>Hi all
> I want to get the Removable devices excluding CD,DVD. I am using the
>following code . Is my approach right?
>
>In this code I am iterating the whole Media and trying to get only removable
>media from them and also eliminate the CD,DVD from them. How i can do
>this?
>
>
>kern_return_t FindAllDrives( io_iterator_t *mediaIterator )
>{
> CFMutableDictionaryRef classesToMatch;
> kern_return_t kernResult = KERN_FAILURE;
> classesToMatch = IOServiceMatching( kIOMediaClass );
> if ( classesToMatch == NULL ) goto Bail;
> CFDictionarySetValue( classesToMatch, CFSTR(kIOMediaWholeKey),
>kCFBooleanTrue );
> kernResult = IOServiceGetMatchingServices( kIOMasterPortDefault,
>classesToMatch, mediaIterator );
> if ( KERN_SUCCESS != kernResult
> qDebug("IOServiceGetMatchingServices returned 0x%08x\n", kernResult );
>
>Bail:
> return( kernResult );
>}
>
>
>
>
> io_iterator_t mediaIterator;
> char bsdPath[ MAXPATHLEN ];
> char ModelNo[ MAXPATHLEN ];
> kernResult = FindAllDrives( &mediaIterator );
> CFIndex maxPathSize;
> maxPathSize=sizeof(bsdPath);
> CFTypeRef bsdPathAsCFString;
> CFTypeRef object;
> io_object_t nextMedia;
> kernResult = KERN_FAILURE;
> *bsdPath = '\0';
> CFNumberRef number = 0;
> CFDictionaryRef properties = 0;
> UInt64 ioSize;
> QString string1;
> QString dwDiskSize;
> while (( nextMedia = IOIteratorNext(mediaIterator)))
> {
> kernResult = IORegistryEntryCreateCFProperties(nextMedia,
>(CFMutableDictionaryRef *)&properties, kCFAllocatorDefault, kNilOptions);
>
> if (KERN_SUCCESS != kernResult)
> {
>
> goto Next;
> }
>
> object = CFDictionaryGetValue( properties, CFSTR(
kIOMediaRemovableKey
>) );
> if ( object )
> {
>
> number = (CFNumberRef) CFDictionaryGetValue(properties,
>CFSTR(kIOMediaSizeKey));
> if(!number)
> QMessageBox::information(0,"Size Missing","kIOMediaSizeKey property
>missing");
> if (!CFNumberGetValue(number, kCFNumberLongLongType, &ioSize))
> {
> goto Next;
> }
> CFDictionaryGetValue(properties, CFSTR(kIOBSDNameKey));
> if ( bsdPathAsCFString )
> {
> size_t devPathLength;
> * bsdPath = '\0';
> strcpy(bsdPath, _PATH_DEV);
> strcat(bsdPath, "r");
> devPathLength = strlen(bsdPath);
> if (CFStringGetCString(bsdPathAsCFString, bsdPath + devPathLength,
>maxPathSize - devPathLength, kCFStringEncodingUTF8))
> {
> string1= QString::null ;
> string1=string1.setNum(ioSize);
> }
> }
>
>
>Thanks
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>Carbon-dev mailing list (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>http://lists.apple.com/mailman/options/carbon-dev/
email@hidden
>
>This email sent to email@hidden
_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.