Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / SafeRegistryHandle.cs / 1 / SafeRegistryHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeRegistryHandle ** ** ** A wrapper for registry handles ** ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { internal sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: Officially -1 is the recommended invalid handle value for // registry keys, but we'll also get back 0 as an invalid handle from // RegOpenKeyEx. [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] internal SafeRegistryHandle() : base(true) {} [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] internal SafeRegistryHandle(IntPtr preexistingHandle, bool ownsHandle) : base(ownsHandle) { SetHandle(preexistingHandle); } [DllImport(Win32Native.ADVAPI32), SuppressUnmanagedCodeSecurity, ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern int RegCloseKey(IntPtr hKey); override protected bool ReleaseHandle() { // Returns a Win32 error code, 0 for success int r = RegCloseKey(handle); return r == 0; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LocalServiceSecuritySettings.cs
- ToolStripItemDesigner.cs
- ComplusEndpointConfigContainer.cs
- MemoryStream.cs
- _HTTPDateParse.cs
- MultipleViewProviderWrapper.cs
- InternalCache.cs
- SqlInternalConnectionTds.cs
- XamlPathDataSerializer.cs
- LinkTarget.cs
- RecordConverter.cs
- SoapUnknownHeader.cs
- ArithmeticException.cs
- EventProviderClassic.cs
- ComponentCommands.cs
- ByteStorage.cs
- DefinitionUpdate.cs
- FixedHighlight.cs
- LambdaCompiler.Address.cs
- CheckBox.cs
- SqlBooleanMismatchVisitor.cs
- MdImport.cs
- ComPersistableTypeElementCollection.cs
- BackgroundFormatInfo.cs
- MatchingStyle.cs
- AccessControlEntry.cs
- RecognizerInfo.cs
- RightsManagementLicense.cs
- KeyedHashAlgorithm.cs
- SequentialUshortCollection.cs
- ToolZone.cs
- EventWaitHandleSecurity.cs
- LabelTarget.cs
- AsyncCompletedEventArgs.cs
- SafeRegistryHandle.cs
- PrintDialogException.cs
- ActivityAction.cs
- EntitySqlQueryBuilder.cs
- WebZone.cs
- Relationship.cs
- RectAnimation.cs
- PropagatorResult.cs
- DefaultAsyncDataDispatcher.cs
- DatePickerAutomationPeer.cs
- DataGridViewColumn.cs
- FormsAuthenticationConfiguration.cs
- InheritedPropertyDescriptor.cs
- PkcsMisc.cs
- FontSourceCollection.cs
- ChannelDispatcher.cs
- ScriptManagerProxy.cs
- Main.cs
- WindowsButton.cs
- PointCollectionConverter.cs
- AutomationPropertyInfo.cs
- RoleGroup.cs
- LicenseException.cs
- UserControl.cs
- StateChangeEvent.cs
- _AutoWebProxyScriptWrapper.cs
- GeometryModel3D.cs
- NamedObject.cs
- ViewSimplifier.cs
- LoginName.cs
- StateItem.cs
- WebBrowserNavigatingEventHandler.cs
- SecurityKeyUsage.cs
- OdbcConnectionHandle.cs
- Rectangle.cs
- SpellerError.cs
- ButtonChrome.cs
- ObjectCloneHelper.cs
- GlobalAclOperationRequirement.cs
- WindowsMenu.cs
- SimpleMailWebEventProvider.cs
- CharacterMetrics.cs
- HandledMouseEvent.cs
- WindowProviderWrapper.cs
- TextEditor.cs
- SpecularMaterial.cs
- PropertyGeneratedEventArgs.cs
- GeneratedCodeAttribute.cs
- DecoderNLS.cs
- TextBlock.cs
- DataSetFieldSchema.cs
- ScrollViewerAutomationPeer.cs
- contentDescriptor.cs
- AnimationException.cs
- NetMsmqSecurityElement.cs
- CompilerGlobalScopeAttribute.cs
- PenThreadWorker.cs
- DependencyProperty.cs
- Utils.cs
- ExceptionWrapper.cs
- DiscoveryClientChannelBase.cs
- ToolStripSystemRenderer.cs
- FlagsAttribute.cs
- AssemblyName.cs
- TableItemStyle.cs
- CollectionCodeDomSerializer.cs