Giter Site home page Giter Site logo

liangjs19 / powermanagerapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ravatsaas/powermanagerapi

0.0 0.0 1.0 27 KB

A managed wrapper for the most important functions in the Windows Power management API

License: MIT License

C# 100.00%

powermanagerapi's Introduction

PowerManagerAPI

A managed wrapper for the most important functions in the Windows Power Management API (powrprof.dll)

Getting Started

Installing the package

You can download the package from NuGet using the following command in the Package Manager Console:

PM> Install-Package PowerManagerAPI -Pre

If you prefer to use the NuGet packege manager in Visual Studio, check the box to include prerelease versions before you search for the package

Writing code

Remember to add the PowerManagerAPI namespace:

using PowerManagerAPI;

Then, you can start using the static PowerManager function to interact with the API. For example, to get the id for the active plan, and then display it's name you can use:

var activePlanGuid = PowerManager.GetActivePlan();
var name = PowerManager.GetPlanName(activePlanGuid);

As long as you remember the PoweManager part, intellisense will probably be enough to figure out the rest, but if you get stuck, have a look in the PowerManagerAPI.Tests project for some more examples.

Getting Help

If you have any question, please contact me through my website at binarypoetry.co.

I'll be happy to answer any questions I can. I am also available for freelance work.

Included Functions

The following API functions are implemented in the wrapper.

  • PowerEnumerate
  • PowerGetActiveScheme
  • PowerSetActiveScheme
  • PowerDuplicateScheme
  • PowerDeleteScheme
  • PowerReadFriendlyName
  • PowerWriteFriendlyName
  • PowerReadDescription
  • PowerWriteDescription
  • PowerReadACValueIndex
  • PowerWriteACValueIndex
  • PowerReadDCValueIndex
  • PowerWriteDCValueIndex

Rather than exposing these methods directly, the wrapper exposes a static class called PowerManager with a number of managed methods that will feel familiar to .Net developers. There are also lookups for Subgroup and Setting Guids, to help you get to the setting you want.

Compatibility

The implemented API functions are available in Windows Vista/Windows Server 2003 and later. Earlier versions of Windows used a different set of power management functions, but since those versions are mostly history, they are out of the scope for this library.

Tests

There is a test project that covers most of the PowerManager. Since this is an API, the tests run against the actual windows API, because even if mocking it were possible it would render the tests useless.

Since the tests are running agains the actual API, they do have side effects, since power plans are created, edited and deleted. The tests do not alter the standard Windows plans, but create and work on their own dummy plans. Conceivably, such a plan could in some cases be left over after running the tests. They can be deleted through the powercfg command line tool or Control Panel.

powermanagerapi's People

Contributors

ravatsaas avatar liangjs19 avatar shaharnu11 avatar

Forkers

mann1x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.