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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SerialErrors.cs
- SmtpMail.cs
- AlignmentYValidation.cs
- RecordsAffectedEventArgs.cs
- TreeBuilderBamlTranslator.cs
- TextMetrics.cs
- ReadOnlyDictionary.cs
- ArraySortHelper.cs
- XmlRootAttribute.cs
- JavaScriptSerializer.cs
- UnknownWrapper.cs
- XmlIncludeAttribute.cs
- Crc32Helper.cs
- RestHandlerFactory.cs
- AuthenticationModuleElementCollection.cs
- ThicknessAnimationUsingKeyFrames.cs
- ThemeDirectoryCompiler.cs
- BindingObserver.cs
- CodeNamespaceImportCollection.cs
- FloaterBaseParagraph.cs
- _Connection.cs
- XmlIgnoreAttribute.cs
- TraceSection.cs
- EventWaitHandleSecurity.cs
- _NTAuthentication.cs
- ThumbAutomationPeer.cs
- FragmentNavigationEventArgs.cs
- RowBinding.cs
- StylusPlugInCollection.cs
- SendActivityDesigner.cs
- TypeBinaryExpression.cs
- InvokeMethodActivity.cs
- GACMembershipCondition.cs
- MessageBox.cs
- TextSelectionProcessor.cs
- ComboBox.cs
- Avt.cs
- BadImageFormatException.cs
- WindowsRegion.cs
- EventLogException.cs
- FrameworkElementFactoryMarkupObject.cs
- DoubleLinkList.cs
- GreenMethods.cs
- WinEventTracker.cs
- SizeF.cs
- Canvas.cs
- RegexCaptureCollection.cs
- XmlTextEncoder.cs
- SrgsOneOf.cs
- ServicePoint.cs
- BitmapVisualManager.cs
- TableItemPatternIdentifiers.cs
- SecurityKeyUsage.cs
- HttpStreamMessage.cs
- HtmlImage.cs
- CollectionContainer.cs
- BinaryNode.cs
- SoapSchemaMember.cs
- CommentAction.cs
- GlobalizationSection.cs
- DataGridViewRowCollection.cs
- LogRestartAreaEnumerator.cs
- ModelPropertyImpl.cs
- ShapingEngine.cs
- DropTarget.cs
- DispatcherEventArgs.cs
- PieceNameHelper.cs
- DataListItemCollection.cs
- WebScriptMetadataFormatter.cs
- LogRecordSequence.cs
- PathFigureCollectionConverter.cs
- UnauthorizedWebPart.cs
- FilterUserControlBase.cs
- HtmlInputCheckBox.cs
- XmlEnumAttribute.cs
- RichTextBoxConstants.cs
- QuerySelectOp.cs
- ListViewDeletedEventArgs.cs
- DataGridDetailsPresenterAutomationPeer.cs
- AliasExpr.cs
- ComponentEvent.cs
- CanonicalizationDriver.cs
- AppDomainProtocolHandler.cs
- BoundColumn.cs
- HtmlUtf8RawTextWriter.cs
- BoundColumn.cs
- IssuerInformation.cs
- IsolatedStorageFilePermission.cs
- Activator.cs
- SessionStateItemCollection.cs
- Symbol.cs
- basemetadatamappingvisitor.cs
- SystemEvents.cs
- Transform.cs
- ObjectListFieldCollection.cs
- ComplexTypeEmitter.cs
- WhitespaceRuleLookup.cs
- FocusTracker.cs
- OneOfElement.cs
- HttpWrapper.cs