Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

SECURITY_ATTRIBUTES (Structures)
 
.
Summary

C# Definition:

[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
    public int nLength;
    public IntPtr lpSecurityDescriptor;
    public int bInheritHandle;    // BOOL
}

VB Definition:

Structure SECURITY_ATTRIBUTES
   Public TODO
End Structure

User-Defined Field Types:

None.

Notes:

Sample
Creating a semaphore with a NULL DACL (allowing full access to everyone)

SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR();
InitializeSecurityDescriptor(ref sd, 1);
SetSecurityDescriptorDacl(ref sd, 1, IntPtr.Zero, 0);
GCHandle sdHandle = GCHandle.Alloc(sd, GCHandleType.Pinned);
try
{
    SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
    sa.nLength = Marshal.SizeOf(sa);
    sa.lpSecurityDescriptor = sdHandle.AddrOfPinnedObject();
    sa.bInheritHandle = 0;

    this.Handle = CreateSemaphore(ref sa, 0, int.MaxValue, name);
    if (Handle.ToInt32() == 0)
    {
        int errNo = (int) GetLastError();
        throw new Win32Exception(errNo , "Error " + errNo + " creating semaphore " + name);
    }
}
finally
{
    sdHandle.Free();
}

Documentation

Please edit this page!

Do you have...

  • helpful tips?
  • corrections to the existing content?
  • alternate definitions?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing any supporting types needed.

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions