[Mono-osx] How to handle CFArrayRef?

Erik Ylvisaker eylvisaker at physics.ucdavis.edu
Mon Apr 21 21:47:22 EDT 2008


You have to call other functions in Core Foundation to get values out of 
the array.  If all you need is the functions CFArrayGetCount and 
CFArrayGetValueAtIndex, you can use the sample code I've attached 
below.  You might also want CFArrayGetValues.  Documentation for the 
CFArray functions is here:
http://developer.apple.com/documentation/CoreFoundation/Reference/CFArrayRef/Reference/reference.html


        const string appServices = 
"/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/ApplicationServices"; 

 
        [DllImport(appServices)]
        internal static extern int CFArrayGetCount(IntPtr theArray);
 
        [DllImport(appServices)]
        internal static extern IntPtr CFArrayGetValueAtIndex(IntPtr 
theArray, int idx);


Sebastian Mauer wrote:
> Hello there,
>
> I'm currently implementing part of the Apple80211.framework, and made good
> progress until now.
> The function WirelessScan will pass me a pointer to a CFArrayRef (part of
> CoreFoundation) which contains several WirelessNetworkInfo structs and I'm
> not sure how to map/handle them within c#
>
> extern WIErr WirelessScan(
> 	WirelessContextPtr inContext,
> 	CFArrayRef *apList,
> 	const UInt32 stripDups);
>
> This is the information I got from the respective header file:
> *  It will allocate 2 CFArrays to store a list
>  *  of managed and adhoc networks. The arrays hold CFData
>  *  objects which contain WirelessNetworkInfo structures.
>
> What can I do to ultimately recieve an Array out of WirelessNetworkInfo
> structs?
>
> Greetings,
>
> Sebastian Mauer
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
>   


More information about the Mono-osx mailing list