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
- TransformGroup.cs
- EditCommandColumn.cs
- ModelChangedEventArgsImpl.cs
- BaseComponentEditor.cs
- XamlInterfaces.cs
- ParameterBuilder.cs
- EntityClassGenerator.cs
- SevenBitStream.cs
- StylusButtonEventArgs.cs
- SystemIPAddressInformation.cs
- HttpListener.cs
- ScrollChrome.cs
- InvariantComparer.cs
- XmlReflectionImporter.cs
- AutomationPropertyInfo.cs
- SqlException.cs
- UnionCodeGroup.cs
- BaseResourcesBuildProvider.cs
- ToolboxDataAttribute.cs
- SafeNativeMethods.cs
- Win32Native.cs
- BuildResult.cs
- Activator.cs
- ProfilePropertySettings.cs
- SafeRightsManagementQueryHandle.cs
- SystemIcmpV6Statistics.cs
- ScriptIgnoreAttribute.cs
- RuntimeWrappedException.cs
- MatrixTransform.cs
- EncryptedPackageFilter.cs
- EditorZoneAutoFormat.cs
- QueryResponse.cs
- TableCell.cs
- CommonDialog.cs
- SamlAssertion.cs
- _ListenerAsyncResult.cs
- UIElementParaClient.cs
- DispatcherTimer.cs
- DBCSCodePageEncoding.cs
- ValidatorUtils.cs
- Parser.cs
- ManualResetEvent.cs
- DefaultBindingPropertyAttribute.cs
- SmtpNetworkElement.cs
- DataBindingHandlerAttribute.cs
- SafeCryptHandles.cs
- NetSectionGroup.cs
- mda.cs
- SoapSchemaMember.cs
- ToolboxItemAttribute.cs
- TypeDependencyAttribute.cs
- ISAPIWorkerRequest.cs
- TransformerInfo.cs
- _PooledStream.cs
- ServicePrincipalNameElement.cs
- httpserverutility.cs
- COM2ColorConverter.cs
- ReadOnlyAttribute.cs
- EntityContainerRelationshipSetEnd.cs
- SqlHelper.cs
- FileDialog.cs
- KeyInterop.cs
- SchemaRegistration.cs
- BaseDataList.cs
- CacheRequest.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- RelationshipSet.cs
- SoapClientProtocol.cs
- IncrementalReadDecoders.cs
- StringStorage.cs
- CodeCatchClauseCollection.cs
- OSFeature.cs
- RpcCryptoRequest.cs
- HtmlTableCellCollection.cs
- TextAnchor.cs
- IIS7UserPrincipal.cs
- AutoGeneratedFieldProperties.cs
- DbMetaDataFactory.cs
- CodeVariableDeclarationStatement.cs
- XhtmlTextWriter.cs
- DbSetClause.cs
- RowUpdatedEventArgs.cs
- TrustManagerPromptUI.cs
- SqlXml.cs
- FormClosingEvent.cs
- SortExpressionBuilder.cs
- TextShapeableCharacters.cs
- BaseParser.cs
- ServiceOperationParameter.cs
- InlinedAggregationOperator.cs
- ProcessHostFactoryHelper.cs
- QueryGenerator.cs
- documentsequencetextview.cs
- CustomTrackingRecord.cs
- CompositeFontFamily.cs
- COM2IProvidePropertyBuilderHandler.cs
- IndexOutOfRangeException.cs
- TileBrush.cs
- Point3D.cs
- OracleDateTime.cs