Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
devicepowerenumdevices (powrprof)
Enumerates devices on the system that meet the specified criteria.

C# Signature:

[DllImport("powrprof.dll", SetLastError=true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool DevicePowerEnumDevices(uint queryIndex, QueryInterpretationFlags queryInterpretationFlags, QueryFlags queryFlags, IntPtr pReturnBuffer, ref uint pBufferSize);

VB Signature:

Declare Function DevicePowerEnumDevices Lib "powrprof.dll" (TODO) As TODO

User-Defined Types:

QueryInterpretationFlags, QueryFlags

Alternative Managed API:

Do you know one? Please contribute it!


If pReturnBuffer is NULL, pBufferSize will be filled with the size needed to return the data.

Tips & Tricks:

Please add some!

Sample Code:

    const int MAX_PATH = 261;

    if (!DevicePowerOpen(0))
        return; // error

    uint size = MAX_PATH;
    IntPtr ptrBuffer = Marshal.AllocHGlobal((int)size);
    uint index = 0;
    bool result = false;
        while ((ptrBuffer != IntPtr.Zero) &&
            (result = DevicePowerEnumDevices(index, QueryInterpretationFlags.DEVICEPOWER_FILTER_DEVICES_PRESENT, QueryFlags.PDCAP_D2_SUPPORTED, ptrBuffer, ref size)) != false)
            string strBuffer = Marshal.PtrToStringUni(ptrBuffer);
            string str = string.Format("Device name: {0}\n", strBuffer);




Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version