private IORegistryEntryGetPath ( int entry, [ plane, io_string_t &path ) : IOReturn | ||
entry | int | |
plane | [ | |
path | io_string_t | |
return | IOReturn |
object[] GetDeviceKeys(string kind) { var paths = new List <NativeMethods.io_string_t>(); var matching = NativeMethods.IOServiceMatching(kind).ToCFType(); // Consumed by IOServiceGetMatchingServices, so DON'T Dispose(). if (matching.IsSet) { int iteratorObj; if (NativeMethods.IOReturn.Success == NativeMethods.IOServiceGetMatchingServices(0, matching, out iteratorObj)) { using (var iterator = iteratorObj.ToIOObject()) { while (true) { using (var handle = NativeMethods.IOIteratorNext(iterator).ToIOObject()) { if (!handle.IsSet) { break; } NativeMethods.io_string_t path; if (NativeMethods.IOReturn.Success == NativeMethods.IORegistryEntryGetPath(handle, "IOService", out path)) { paths.Add(path); } } } } } } return(paths.Cast <object>().ToArray()); }