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
- InvalidDataContractException.cs
- ApplicationManager.cs
- MethodCallTranslator.cs
- SaveFileDialog.cs
- EnterpriseServicesHelper.cs
- COM2EnumConverter.cs
- TypeConverterValueSerializer.cs
- DecodeHelper.cs
- RangeBaseAutomationPeer.cs
- ModelUtilities.cs
- ISessionStateStore.cs
- Comparer.cs
- DataGridViewRowPostPaintEventArgs.cs
- CommentEmitter.cs
- XmlReaderSettings.cs
- DropDownHolder.cs
- ChannelManagerService.cs
- ExpressionWriter.cs
- GeometryModel3D.cs
- HwndHostAutomationPeer.cs
- TypeTypeConverter.cs
- handlecollector.cs
- unsafeIndexingFilterStream.cs
- Base64WriteStateInfo.cs
- CodeChecksumPragma.cs
- Schema.cs
- CodeGenerator.cs
- LateBoundBitmapDecoder.cs
- NativeRecognizer.cs
- SubclassTypeValidatorAttribute.cs
- AbsoluteQuery.cs
- hebrewshape.cs
- RtfToXamlReader.cs
- SafePipeHandle.cs
- TimeSpanMinutesConverter.cs
- FontFamilyValueSerializer.cs
- SplineKeyFrames.cs
- xml.cs
- SingleResultAttribute.cs
- DropShadowBitmapEffect.cs
- ListBase.cs
- MenuItemStyle.cs
- DesignerForm.cs
- M3DUtil.cs
- DocumentPageTextView.cs
- XmlDsigSep2000.cs
- DataTableCollection.cs
- DeviceContext2.cs
- ToolStripPanelRow.cs
- Char.cs
- FormsAuthenticationTicket.cs
- EntityDataSourceReferenceGroup.cs
- ExpressionHelper.cs
- COM2FontConverter.cs
- WindowInteropHelper.cs
- FormsAuthenticationUserCollection.cs
- SynchronizedInputAdaptor.cs
- Internal.cs
- ListSourceHelper.cs
- SqlServices.cs
- HtmlTernaryTree.cs
- MouseButton.cs
- ListItemConverter.cs
- AuthenticationManager.cs
- TypeUtil.cs
- ListBoxAutomationPeer.cs
- ChannelManagerService.cs
- SoundPlayer.cs
- AutomationProperty.cs
- Solver.cs
- XmlReflectionMember.cs
- PersonalizationStateQuery.cs
- SearchForVirtualItemEventArgs.cs
- GetTokenRequest.cs
- PropertyEmitter.cs
- DbConnectionInternal.cs
- TraceUtils.cs
- XmlIlVisitor.cs
- WebPartVerbCollection.cs
- Annotation.cs
- MSG.cs
- ProjectionPruner.cs
- DefaultEventAttribute.cs
- SQLString.cs
- CloudCollection.cs
- ITextView.cs
- securitycriticaldata.cs
- SQLDoubleStorage.cs
- Int16Converter.cs
- ResourceLoader.cs
- TreeViewItemAutomationPeer.cs
- ClientApiGenerator.cs
- TextRenderer.cs
- ListControl.cs
- AuthenticateEventArgs.cs
- HttpBrowserCapabilitiesWrapper.cs
- DrawingState.cs
- DataGridItemEventArgs.cs
- SrgsText.cs
- CatalogPartCollection.cs