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
- DataSourceHelper.cs
- CalendarDateChangedEventArgs.cs
- Executor.cs
- AndCondition.cs
- ComponentManagerBroker.cs
- SortQuery.cs
- returneventsaver.cs
- RichTextBoxAutomationPeer.cs
- SR.Designer.cs
- SettingsSection.cs
- RightsManagementInformation.cs
- HelpInfo.cs
- TagPrefixCollection.cs
- MultiDataTrigger.cs
- DeclarationUpdate.cs
- ThreadExceptionDialog.cs
- BuilderPropertyEntry.cs
- WeakReference.cs
- IssuanceLicense.cs
- TextPattern.cs
- LiteralTextContainerControlBuilder.cs
- OracleBinary.cs
- TripleDESCryptoServiceProvider.cs
- DataGridCell.cs
- ExpressionParser.cs
- OwnerDrawPropertyBag.cs
- CodeNamespace.cs
- WinEventTracker.cs
- DialogResultConverter.cs
- xdrvalidator.cs
- ObjectDataSourceMethodEditor.cs
- GridEntry.cs
- ColumnWidthChangingEvent.cs
- BamlLocalizableResourceKey.cs
- DomainConstraint.cs
- SchemaExporter.cs
- InstanceHandleReference.cs
- SqlCommandAsyncResult.cs
- DataSourceSelectArguments.cs
- PagerSettings.cs
- WriteableBitmap.cs
- PackageController.cs
- EdmValidator.cs
- HtmlForm.cs
- CryptographicAttribute.cs
- VideoDrawing.cs
- ProtocolViolationException.cs
- _RequestCacheProtocol.cs
- BrowserCapabilitiesFactoryBase.cs
- StagingAreaInputItem.cs
- DependencyPropertyChangedEventArgs.cs
- EventLogger.cs
- LambdaCompiler.ControlFlow.cs
- LinkLabelLinkClickedEvent.cs
- HyperLinkField.cs
- VersionedStreamOwner.cs
- DataControlImageButton.cs
- BookmarkScope.cs
- EvidenceBase.cs
- ModuleConfigurationInfo.cs
- MetadataItemSerializer.cs
- ToolStripRendererSwitcher.cs
- BitmapSourceSafeMILHandle.cs
- StringWriter.cs
- KeyFrames.cs
- WinEventTracker.cs
- UTF8Encoding.cs
- ThreadExceptionDialog.cs
- ParseHttpDate.cs
- RemotingClientProxy.cs
- UntypedNullExpression.cs
- Stream.cs
- SourceFilter.cs
- DrawListViewItemEventArgs.cs
- CLSCompliantAttribute.cs
- ItemTypeToolStripMenuItem.cs
- elementinformation.cs
- DetailsViewDesigner.cs
- AlphaSortedEnumConverter.cs
- DataGridViewComboBoxEditingControl.cs
- SchemaImporter.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- Types.cs
- TransactedBatchingBehavior.cs
- CustomAssemblyResolver.cs
- LinqDataSource.cs
- DrawingVisual.cs
- ComboBoxRenderer.cs
- AutomationElement.cs
- OutputScopeManager.cs
- TextReader.cs
- MsmqReceiveHelper.cs
- PerformanceCounterPermission.cs
- TileBrush.cs
- SiteMapDataSourceView.cs
- ellipse.cs
- BaseResourcesBuildProvider.cs
- VerificationException.cs
- AttributeQuery.cs
- DescendantBaseQuery.cs