SafeRegistryKey.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / SafeRegistryKey.cs / 1305376 / SafeRegistryKey.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace Microsoft.Tools.ServiceModel.WsatConfig 
{
    using System; 
    using System.Security; 
    using System.Security.Permissions;
    using System.Runtime.InteropServices; 
    using System.Runtime.CompilerServices;
    using System.Runtime.ConstrainedExecution;
    using Microsoft.Win32.SafeHandles;
 
    sealed class SafeRegistryKey : SafeHandleZeroOrMinusOneIsInvalid
    { 
        [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] 
        internal SafeRegistryKey() : base(false) { }
 
        [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
        internal SafeRegistryKey(IntPtr preexistingHandle, bool ownsHandle)
            : base(ownsHandle)
        { 
            SetHandle(preexistingHandle);
        } 
 
        protected override bool ReleaseHandle()
        { 
            // Returns a Win32 error code, 0 for success
            int r = SafeNativeMethods.RegCloseKey(handle);
            return r == 0;
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK