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
- KeyEvent.cs
- TreeView.cs
- CodeAccessSecurityEngine.cs
- ListBoxAutomationPeer.cs
- UpDownEvent.cs
- InputGestureCollection.cs
- IndexOutOfRangeException.cs
- TextEndOfParagraph.cs
- NavigateEvent.cs
- ModelUIElement3D.cs
- DotExpr.cs
- SQLByteStorage.cs
- CachedPathData.cs
- TaskScheduler.cs
- XmlSerializerAssemblyAttribute.cs
- TranslateTransform3D.cs
- JumpList.cs
- TrackingProfileDeserializationException.cs
- DataGridViewImageCell.cs
- RightsManagementEncryptionTransform.cs
- ErrorWrapper.cs
- ToolStripRenderer.cs
- StrongNameIdentityPermission.cs
- ContourSegment.cs
- HttpApplicationFactory.cs
- MimeParameters.cs
- SpecularMaterial.cs
- MouseButton.cs
- MultiAsyncResult.cs
- CompiledIdentityConstraint.cs
- KnownColorTable.cs
- returneventsaver.cs
- _Rfc2616CacheValidators.cs
- StandardMenuStripVerb.cs
- FilteredReadOnlyMetadataCollection.cs
- SecurityElement.cs
- SessionPageStateSection.cs
- Listbox.cs
- AdvancedBindingPropertyDescriptor.cs
- HttpModuleCollection.cs
- TextBounds.cs
- UserControlCodeDomTreeGenerator.cs
- DoubleIndependentAnimationStorage.cs
- ToolbarAUtomationPeer.cs
- SchemaTableColumn.cs
- Rights.cs
- FlowDecisionDesigner.xaml.cs
- JsonXmlDataContract.cs
- CompilerResults.cs
- RadioButtonRenderer.cs
- ModulesEntry.cs
- OperandQuery.cs
- MemberRelationshipService.cs
- SelectorAutomationPeer.cs
- NullableBoolConverter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- SimpleWebHandlerParser.cs
- ImageUrlEditor.cs
- DoubleIndependentAnimationStorage.cs
- CreateSequenceResponse.cs
- GZipDecoder.cs
- EntityDataSourceValidationException.cs
- PasswordDeriveBytes.cs
- Image.cs
- NullableDecimalSumAggregationOperator.cs
- SmtpException.cs
- DataGridViewAccessibleObject.cs
- DBDataPermission.cs
- DataGridViewTextBoxColumn.cs
- UserControlParser.cs
- XmlAttributeAttribute.cs
- MasterPage.cs
- TypeSemantics.cs
- ToolStripScrollButton.cs
- DockPattern.cs
- TableMethodGenerator.cs
- SpellerHighlightLayer.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- EncoderNLS.cs
- HostedHttpContext.cs
- StylusLogic.cs
- DataViewManager.cs
- SiteOfOriginContainer.cs
- ValidationUtility.cs
- StreamGeometry.cs
- ECDsa.cs
- SqlDataSourceFilteringEventArgs.cs
- WebConfigManager.cs
- SimpleFileLog.cs
- ImportOptions.cs
- MaterialGroup.cs
- TraceContextRecord.cs
- MetadataProperty.cs
- dbdatarecord.cs
- BindingNavigator.cs
- _ScatterGatherBuffers.cs
- ThreadAttributes.cs
- BitmapEncoder.cs
- MultiPartWriter.cs
- PostBackOptions.cs