Code:
/ FX-1434 / FX-1434 / 1.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
- ContentPresenter.cs
- IgnoreSection.cs
- CheckBoxPopupAdapter.cs
- StringCollectionEditor.cs
- BookmarkInfo.cs
- AsyncStreamReader.cs
- WindowPatternIdentifiers.cs
- DataPagerField.cs
- BuiltInExpr.cs
- DbProviderFactories.cs
- HostingEnvironment.cs
- ElementHostPropertyMap.cs
- SmiEventSink.cs
- ArrayConverter.cs
- DefaultProfileManager.cs
- CancellationState.cs
- StrokeRenderer.cs
- RelationshipFixer.cs
- DiffuseMaterial.cs
- TypeForwardedToAttribute.cs
- GestureRecognizer.cs
- ControlCachePolicy.cs
- TextEditorCopyPaste.cs
- Memoizer.cs
- RowParagraph.cs
- TextTabProperties.cs
- DesignerLoader.cs
- DiagnosticTrace.cs
- EndOfStreamException.cs
- ParagraphVisual.cs
- DataBoundLiteralControl.cs
- ValidatorCollection.cs
- StyleReferenceConverter.cs
- BezierSegment.cs
- RectAnimationClockResource.cs
- GZipDecoder.cs
- AnnotationAdorner.cs
- CompatibleIComparer.cs
- ParallelTimeline.cs
- SvcMapFileLoader.cs
- TrackingDataItem.cs
- UnsafeNativeMethodsCLR.cs
- XamlDesignerSerializationManager.cs
- QilPatternVisitor.cs
- Misc.cs
- RadialGradientBrush.cs
- AccessibilityHelperForVista.cs
- SQLChars.cs
- MessageFormatterConverter.cs
- TextBoxRenderer.cs
- PartDesigner.cs
- TransformDescriptor.cs
- OleDbConnectionFactory.cs
- XmlDeclaration.cs
- EmptyCollection.cs
- SchemaAttDef.cs
- ByteKeyFrameCollection.cs
- TableCell.cs
- DataGridToolTip.cs
- XmlTextReaderImpl.cs
- GlyphInfoList.cs
- StrokeCollection.cs
- DataTransferEventArgs.cs
- DBPropSet.cs
- XmlSchemaDocumentation.cs
- Literal.cs
- AgileSafeNativeMemoryHandle.cs
- _TransmitFileOverlappedAsyncResult.cs
- IncrementalHitTester.cs
- URL.cs
- TypedTableGenerator.cs
- XamlGridLengthSerializer.cs
- XmlSchemaComplexType.cs
- _Semaphore.cs
- LayoutEditorPart.cs
- CustomAttributeBuilder.cs
- HistoryEventArgs.cs
- SerializableAttribute.cs
- Merger.cs
- SaveLedgerEntryRequest.cs
- Crc32Helper.cs
- ComEventsHelper.cs
- TextClipboardData.cs
- SqlConnectionPoolProviderInfo.cs
- Image.cs
- DelegateBodyWriter.cs
- ArraySortHelper.cs
- AttributeCollection.cs
- XmlQueryCardinality.cs
- Configuration.cs
- DecoderReplacementFallback.cs
- ListViewInsertEventArgs.cs
- MimeXmlImporter.cs
- CategoryGridEntry.cs
- HttpGetProtocolReflector.cs
- LiteralControl.cs
- UserPreference.cs
- OleDbFactory.cs
- UnsafeNativeMethods.cs
- ListViewSortEventArgs.cs