protected override void LoadChilds() { IntPtr ptrToPowerSchemeGuid = IntPtr.Zero; try { uint buffSize = 100; uint schemeIndex = 0; ptrToPowerSchemeGuid = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))); //Get the guids of all available power schemes. while (NativeMethods.PowerEnumerate( IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, NativeMethods.PowerDataAccessor.AccessScheme, schemeIndex, ptrToPowerSchemeGuid, ref buffSize) == 0) { Guid schemeGuid = (Guid)Marshal.PtrToStructure( ptrToPowerSchemeGuid, typeof(Guid)); SchemeNode n = new SchemeNode(schemeGuid, settings); childs.Add(n); schemeIndex++; } } catch (Exception exception) { throw new PowerManagerException(exception.Message, exception); } finally { Marshal.FreeHGlobal(ptrToPowerSchemeGuid); } }
protected override void LoadChilds() { IntPtr ptrToPowerSchemeGuid = IntPtr.Zero; try { uint buffSize = 100; uint schemeIndex = 0; ptrToPowerSchemeGuid = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Guid))); //Get the guids of all available power schemes. while (NativeMethods.PowerEnumerate( IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, NativeMethods.PowerDataAccessor.AccessScheme, schemeIndex, ptrToPowerSchemeGuid, ref buffSize) == 0) { Guid schemeGuid = (Guid)Marshal.PtrToStructure( ptrToPowerSchemeGuid, typeof(Guid)); SchemeNode n = new SchemeNode(schemeGuid, settings); childs.Add( n ); schemeIndex++; } } catch (Exception exception) { throw new PowerManagerException(exception.Message, exception); } finally { Marshal.FreeHGlobal(ptrToPowerSchemeGuid); } }