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
LookupPrivilegeDisplayName (advapi32)
Returns the display name for a privilege when provided with the system name.

C# Signature:

[DllImport("advapi32.dll", SetLastError=true)]
static extern bool LookupPrivilegeDisplayName(
    string systemName,
    string privilegeName, //in
    System.Text.StringBuilder displayName,  // out
    ref uint cbDisplayName,
    out uint languageId

VB Signature:

Declare Function LookupPrivilegeDisplayName Lib "advapi32.dll" (TODO) As TODO

User-Defined Types:



If it returns false, you'll need to call Marshal.GetLastWin32Error() and handle at least these errors:


This is one of those "call twice" functions, so this error is just daily life. When it returns with this error, the byte count (cbDisplayName) will be set to what you need. Call EnsureCapacity on your StringBuilder and go round again.

const int ERROR_NO_SUCH_PRIVILEGE = 1313;

The privileges that Windows knows about vary from one system to another. If you run your code on a Windows version other than the one you developed it on, you'll need to handle this one.

TODO Does anyone know where to find a definitive reference for which privileges are present on a given OS? There doesn't seem to be an enumeration function

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!


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