Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XamlFigureLengthSerializer.cs
- CryptoStream.cs
- HttpException.cs
- CmsInterop.cs
- RemotingServices.cs
- PublisherIdentityPermission.cs
- RemotingAttributes.cs
- SafePEFileHandle.cs
- DocobjHost.cs
- SecurityTokenTypes.cs
- StackSpiller.cs
- AutomationAttributeInfo.cs
- Registry.cs
- Mutex.cs
- DataRowChangeEvent.cs
- ProfilePropertySettings.cs
- LassoSelectionBehavior.cs
- TransformBlockRequest.cs
- HtmlInputText.cs
- EmptyCollection.cs
- DeclarativeCatalogPart.cs
- EventLog.cs
- UnionCodeGroup.cs
- ConfigPathUtility.cs
- LineBreak.cs
- NativeRightsManagementAPIsStructures.cs
- NonParentingControl.cs
- DataGridPageChangedEventArgs.cs
- StreamUpgradeBindingElement.cs
- RegexCaptureCollection.cs
- PackagingUtilities.cs
- ColorTransform.cs
- SafeNativeMethodsMilCoreApi.cs
- XmlHelper.cs
- EnumUnknown.cs
- ReflectionUtil.cs
- AddInEnvironment.cs
- WebPartDisplayModeCancelEventArgs.cs
- ServiceHostingEnvironment.cs
- DbProviderManifest.cs
- Int32KeyFrameCollection.cs
- TextSegment.cs
- TypedRowGenerator.cs
- LinqDataSourceDeleteEventArgs.cs
- TreeBuilder.cs
- DbModificationClause.cs
- ComponentGlyph.cs
- activationcontext.cs
- EntityDataSourceWrapperCollection.cs
- TextHidden.cs
- Substitution.cs
- InternalConfigEventArgs.cs
- ObjectNotFoundException.cs
- Compiler.cs
- ApplicationInfo.cs
- EventInfo.cs
- xsdvalidator.cs
- SortQuery.cs
- DbProviderSpecificTypePropertyAttribute.cs
- VisualTreeUtils.cs
- SQLByte.cs
- CacheMode.cs
- BuildProvider.cs
- CodeExpressionStatement.cs
- DynamicPropertyReader.cs
- ToolboxItemSnapLineBehavior.cs
- HttpErrorTraceRecord.cs
- ExpressionConverter.cs
- WSSecurityPolicy11.cs
- DataGridViewImageCell.cs
- DelayedRegex.cs
- ProfilePropertySettings.cs
- MailAddressCollection.cs
- MissingFieldException.cs
- CurrencyWrapper.cs
- DataObjectPastingEventArgs.cs
- DependencyPropertyConverter.cs
- ObjectAnimationUsingKeyFrames.cs
- XmlC14NWriter.cs
- RuntimeResourceSet.cs
- HtmlInputFile.cs
- SizeKeyFrameCollection.cs
- DesignTimeTemplateParser.cs
- HyperLinkField.cs
- ImageIndexConverter.cs
- SoapEnvelopeProcessingElement.cs
- storepermission.cs
- FloaterBaseParaClient.cs
- ProjectionPruner.cs
- VScrollProperties.cs
- LayoutInformation.cs
- SchemaSetCompiler.cs
- ResourcePermissionBase.cs
- ProtocolsConfigurationEntry.cs
- DeploymentSection.cs
- LayoutInformation.cs
- NodeInfo.cs
- ProgressiveCrcCalculatingStream.cs
- SQLMoneyStorage.cs
- assemblycache.cs