Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / RegistryHandle.cs / 1 / RegistryHandle.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Install { using Microsoft.Win32.SafeHandles; using System.ComponentModel; using System.Text; class RegistryHandle : SafeHandleZeroOrMinusOneIsInvalid { static readonly RegistryHandle HKEY_LOCAL_MACHINE = new RegistryHandle(new IntPtr(unchecked((int)0x80000002)), false); const uint KEY_QUERY_VALUE = 0x0001; const uint KEY_WOW64_64KEY = 0x0100; const int REG_SZ = 1; RegistryHandle(IntPtr hKey, bool ownHandle) : base(ownHandle) { handle = hKey; } RegistryHandle() : base(true) { // empty } public static RegistryHandle OpenNativeHKLMSubkey(string subKey) { RegistryHandle result; const uint samDesired = KEY_QUERY_VALUE | KEY_WOW64_64KEY; int status = NativeMethods.RegOpenKeyEx(RegistryHandle.HKEY_LOCAL_MACHINE, subKey, 0, samDesired, out result); if (status != ErrorCodes.ERROR_SUCCESS) { throw new Win32Exception(status); } return result; } public string QueryStringValue(string value) { int type; int sizeInBytes = 0; int status = NativeMethods.RegQueryValueEx(this, value, null, out type, null, ref sizeInBytes); if (status != ErrorCodes.ERROR_SUCCESS) { throw new Win32Exception(status); } if (type != REG_SZ) { throw new InvalidOperationException(SR.GetString(SR.QueryStringValueTypeMismatch, value, type)); } StringBuilder builder = new StringBuilder(sizeInBytes / sizeof(char)); status = NativeMethods.RegQueryValueEx(this, value, null, out type, builder, ref sizeInBytes); if (status != ErrorCodes.ERROR_SUCCESS) { throw new Win32Exception(status); } return builder.ToString(); } protected override bool ReleaseHandle() { return (NativeMethods.RegCloseKey(handle) == ErrorCodes.ERROR_SUCCESS); } } } // 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
- Rect3DConverter.cs
- Line.cs
- OleDbCommand.cs
- MetadataPropertyvalue.cs
- SmiEventSink.cs
- PolyLineSegment.cs
- DescendentsWalker.cs
- RowsCopiedEventArgs.cs
- CodeArrayCreateExpression.cs
- ActionItem.cs
- XmlWriterTraceListener.cs
- CodeDelegateInvokeExpression.cs
- StringAnimationUsingKeyFrames.cs
- WindowAutomationPeer.cs
- SoapConverter.cs
- XmlDataImplementation.cs
- DelegatingTypeDescriptionProvider.cs
- TreeNodeCollection.cs
- KeyToListMap.cs
- CopyOfAction.cs
- KeyFrames.cs
- StyleCollectionEditor.cs
- CheckedListBox.cs
- AvTraceDetails.cs
- RichTextBox.cs
- Buffer.cs
- VersionPair.cs
- RefreshEventArgs.cs
- RelativeSource.cs
- LabelEditEvent.cs
- XmlCharCheckingReader.cs
- CultureMapper.cs
- CompilerGlobalScopeAttribute.cs
- PolyLineSegmentFigureLogic.cs
- BevelBitmapEffect.cs
- Types.cs
- MulticastDelegate.cs
- EventLogEntry.cs
- Mutex.cs
- ProtocolsConfigurationHandler.cs
- DesigntimeLicenseContext.cs
- SqlCacheDependencyDatabaseCollection.cs
- ReadOnlyDictionary.cs
- PointAnimationUsingKeyFrames.cs
- TrackingServices.cs
- EventEntry.cs
- LateBoundBitmapDecoder.cs
- SelectionUIService.cs
- VariantWrapper.cs
- ContentDesigner.cs
- ServiceNotStartedException.cs
- FixedTextContainer.cs
- NavigationEventArgs.cs
- XmlQueryRuntime.cs
- PermissionSet.cs
- TypeBuilder.cs
- CustomTypeDescriptor.cs
- BamlLocalizableResourceKey.cs
- PerfCounters.cs
- Attributes.cs
- DefaultHttpHandler.cs
- ProfileService.cs
- WeakReadOnlyCollection.cs
- TemplateParser.cs
- ClientScriptItem.cs
- GuidelineCollection.cs
- ConfigsHelper.cs
- TreeView.cs
- DbConvert.cs
- EastAsianLunisolarCalendar.cs
- CrossContextChannel.cs
- WindowsNonControl.cs
- NotFiniteNumberException.cs
- DataGridViewRowEventArgs.cs
- CollectionViewSource.cs
- TTSEngineTypes.cs
- MatrixIndependentAnimationStorage.cs
- PropertyMap.cs
- XmlParserContext.cs
- TypeDelegator.cs
- TransactedBatchContext.cs
- XsltException.cs
- TemplateColumn.cs
- DecoderNLS.cs
- GZipDecoder.cs
- ObjectIDGenerator.cs
- XmlSignatureManifest.cs
- RecordsAffectedEventArgs.cs
- DataGridGeneralPage.cs
- clipboard.cs
- CryptoStream.cs
- EntityClassGenerator.cs
- EntityDataSourceDesigner.cs
- MenuAutomationPeer.cs
- TemplatedMailWebEventProvider.cs
- NameObjectCollectionBase.cs
- ReflectEventDescriptor.cs
- DataSourceControl.cs
- MissingSatelliteAssemblyException.cs
- FlowDocumentReader.cs