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
- ClientUtils.cs
- StylusDevice.cs
- BevelBitmapEffect.cs
- _AutoWebProxyScriptEngine.cs
- Psha1DerivedKeyGeneratorHelper.cs
- ErrorInfoXmlDocument.cs
- ClientUtils.cs
- RelationalExpressions.cs
- TokenBasedSet.cs
- GlyphingCache.cs
- MenuItemCollectionEditorDialog.cs
- MULTI_QI.cs
- TextTreeFixupNode.cs
- TypeDescriptionProviderAttribute.cs
- CommonRemoteMemoryBlock.cs
- RuntimeDelegateArgument.cs
- WebPartTransformer.cs
- SettingsProperty.cs
- ConnectionManagementElementCollection.cs
- SqlUserDefinedTypeAttribute.cs
- ControlValuePropertyAttribute.cs
- ConfigXmlText.cs
- ToolStripItemImageRenderEventArgs.cs
- Exceptions.cs
- TextEditorTyping.cs
- SqlBuilder.cs
- DataService.cs
- DriveNotFoundException.cs
- InputProcessorProfilesLoader.cs
- StringValueConverter.cs
- BamlBinaryWriter.cs
- EasingKeyFrames.cs
- ScriptingSectionGroup.cs
- FamilyMapCollection.cs
- IgnoreDeviceFilterElementCollection.cs
- ListParaClient.cs
- CompositeDataBoundControl.cs
- ConfigurationErrorsException.cs
- PenThreadWorker.cs
- TemplateBuilder.cs
- SpellerHighlightLayer.cs
- EditorBrowsableAttribute.cs
- EntryIndex.cs
- DisableDpiAwarenessAttribute.cs
- ReferentialConstraint.cs
- CaseKeyBox.ViewModel.cs
- LicenseContext.cs
- UrlMappingsSection.cs
- SerTrace.cs
- WorkflowView.cs
- TextDecoration.cs
- GacUtil.cs
- DataRowChangeEvent.cs
- SchemaTableColumn.cs
- ExpanderAutomationPeer.cs
- DetailsViewRow.cs
- InstanceKeyView.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- SrgsRulesCollection.cs
- WeakReferenceList.cs
- _CommandStream.cs
- ExpandableObjectConverter.cs
- InvalidPropValue.cs
- DbProviderFactory.cs
- InvalidAsynchronousStateException.cs
- DataSet.cs
- WMIInterop.cs
- XhtmlBasicControlAdapter.cs
- AsyncSerializedWorker.cs
- NativeMethodsOther.cs
- Queue.cs
- TableColumn.cs
- TemplateControlBuildProvider.cs
- DataViewSetting.cs
- PropertyFilterAttribute.cs
- ComNativeDescriptor.cs
- RectangleHotSpot.cs
- EntityClientCacheKey.cs
- BaseConfigurationRecord.cs
- DataView.cs
- CmsUtils.cs
- StrokeCollectionConverter.cs
- PageTheme.cs
- SoapServerProtocol.cs
- RegisteredExpandoAttribute.cs
- WindowsMenu.cs
- _Rfc2616CacheValidators.cs
- EncodedStreamFactory.cs
- SettingsPropertyValueCollection.cs
- SafeEventLogWriteHandle.cs
- RegexFCD.cs
- SimpleWebHandlerParser.cs
- CodeEntryPointMethod.cs
- webbrowsersite.cs
- InfoCardProofToken.cs
- COM2ComponentEditor.cs
- AdjustableArrowCap.cs
- TypeLoadException.cs
- CompoundFileStorageReference.cs
- TypeElement.cs