[Mono-osx] How to handle CFArrayRef?
sebastian.mauer at rwth-aachen.de
Tue Apr 22 15:58:04 EDT 2008
I solved my problem, after getting a IntPtr for each Element within
The Array I could get another IntPtr pointing at the data via
With this IntPtr, Marshal.PtrToStructure worked like a charm.
Von: Erik Ylvisaker [mailto:eylvisaker at physics.ucdavis.edu]
Gesendet: Dienstag, 22. April 2008 21:39
An: Sebastian Mauer
Cc: mono-osx at lists.ximian.com
Betreff: Re: AW: [Mono-osx] How to handle CFArrayRef?
I think you would want to use CFDataGetBytes to copy the data to a
region you allocate with Marshal.AllocHGlobal. Then I think
Marshal.PtrToStructure would be used.
Sebastian Mauer wrote:
> Hello Erik,
> thanks for that hint. So I'm able to read an IntPtr for each entry within
> CFArray. My Header File says "the arrays hold CFData objects which contain
> WirelessNetworkInfo structures",
> So I guess I have to implement some part of CFData as well. If I had a
> pointer to the CFData's contents could I use Marshal.PtrToStructure to
> finally get my WirelessNetworkInfo structs?
> -----Ursprüngliche Nachricht-----
> Von: Erik Ylvisaker [mailto:eylvisaker at physics.ucdavis.edu]
> Gesendet: Dienstag, 22. April 2008 03:47
> An: Sebastian Mauer; mono-osx at lists.ximian.com
> Betreff: Re: [Mono-osx] How to handle CFArrayRef?
> 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:
> const string appServices =
> internal static extern int CFArrayGetCount(IntPtr theArray);
> 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
>> progress until now.
>> The function WirelessScan will pass me a pointer to a CFArrayRef (part of
>> CoreFoundation) which contains several WirelessNetworkInfo structs and
>> 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
>> Sebastian Mauer
>> Mono-osx mailing list
>> Mono-osx at lists.ximian.com
More information about the Mono-osx