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
- DateTimeConstantAttribute.cs
- CodeSnippetExpression.cs
- SaveFileDialog.cs
- XmlSubtreeReader.cs
- WebBaseEventKeyComparer.cs
- SecurityException.cs
- ActiveDocumentEvent.cs
- DbgCompiler.cs
- RelationshipDetailsRow.cs
- AnonymousIdentificationSection.cs
- PlainXmlDeserializer.cs
- PopupRoot.cs
- StructuralComparisons.cs
- SHA1Cng.cs
- PrintPreviewControl.cs
- SecurityUtils.cs
- DisposableCollectionWrapper.cs
- ProtocolsSection.cs
- X509ChainPolicy.cs
- updatecommandorderer.cs
- BuildTopDownAttribute.cs
- JournalEntryListConverter.cs
- _UriTypeConverter.cs
- UInt32.cs
- Config.cs
- SafeNativeMethodsOther.cs
- WebBrowserBase.cs
- IndicCharClassifier.cs
- WindowsFormsHost.cs
- OleDbRowUpdatingEvent.cs
- VirtualizedItemPattern.cs
- SqlXmlStorage.cs
- AutomationElement.cs
- ClientUrlResolverWrapper.cs
- TreeBuilderXamlTranslator.cs
- ParameterCollectionEditorForm.cs
- EncoderFallback.cs
- EventManager.cs
- DbgCompiler.cs
- PasswordRecovery.cs
- SettingsContext.cs
- BoolExpr.cs
- SqlCacheDependency.cs
- DataRelationCollection.cs
- AsyncCompletedEventArgs.cs
- CaseInsensitiveComparer.cs
- GeneralTransform3DTo2D.cs
- ObjectQueryExecutionPlan.cs
- BamlCollectionHolder.cs
- ProjectionPruner.cs
- VisualBrush.cs
- xmlformatgeneratorstatics.cs
- HandlerMappingMemo.cs
- SqlMetaData.cs
- FontFamily.cs
- AuthenticationService.cs
- ToolStripRenderEventArgs.cs
- ColorAnimationUsingKeyFrames.cs
- RepeaterCommandEventArgs.cs
- AssemblyFilter.cs
- RTLAwareMessageBox.cs
- XmlSerializerNamespaces.cs
- Sequence.cs
- PostBackTrigger.cs
- SignedPkcs7.cs
- nulltextcontainer.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- ServiceProviders.cs
- SqlFunctionAttribute.cs
- PropertyIDSet.cs
- StrokeNodeData.cs
- Composition.cs
- LineSegment.cs
- StatusBarDrawItemEvent.cs
- RectangleGeometry.cs
- ServiceHostingEnvironmentSection.cs
- SystemException.cs
- MSAAEventDispatcher.cs
- InvalidWMPVersionException.cs
- DataContractSerializer.cs
- StylusButton.cs
- StorageEntitySetMapping.cs
- coordinatorscratchpad.cs
- EllipseGeometry.cs
- ProxyElement.cs
- AdornerLayer.cs
- XmlWriter.cs
- ToggleButton.cs
- PageContentAsyncResult.cs
- PreProcessInputEventArgs.cs
- ParentQuery.cs
- EditingScope.cs
- SystemSounds.cs
- KeyFrames.cs
- TreeViewImageGenerator.cs
- StickyNote.cs
- WebPartZoneCollection.cs
- FormatConvertedBitmap.cs
- PackUriHelper.cs
- IRCollection.cs