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
- ToolStripKeyboardHandlingService.cs
- URLIdentityPermission.cs
- UnaryNode.cs
- AssociatedControlConverter.cs
- Wizard.cs
- Gdiplus.cs
- TranslateTransform.cs
- Events.cs
- RequestCachingSection.cs
- TextFormatterImp.cs
- XmlSubtreeReader.cs
- ObjectQueryProvider.cs
- CapabilitiesPattern.cs
- BitmapEffectDrawingContent.cs
- DateTimeFormatInfoScanner.cs
- OleDbFactory.cs
- CellLabel.cs
- TypeConstant.cs
- CompositeFontFamily.cs
- RectangleConverter.cs
- Code.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- BinarySerializer.cs
- ImageCodecInfo.cs
- XamlTreeBuilder.cs
- NativeMethods.cs
- CorrelationService.cs
- PropertyGridDesigner.cs
- IriParsingElement.cs
- DATA_BLOB.cs
- BStrWrapper.cs
- DataQuery.cs
- TextDecorationLocationValidation.cs
- SimpleRecyclingCache.cs
- GroupQuery.cs
- ConstructorBuilder.cs
- KeyValueConfigurationElement.cs
- XmlQuerySequence.cs
- WebPartMinimizeVerb.cs
- StrongNameUtility.cs
- DependencyProperty.cs
- VBIdentifierTrimConverter.cs
- XhtmlBasicPageAdapter.cs
- StylusOverProperty.cs
- CheckBoxFlatAdapter.cs
- MULTI_QI.cs
- RangeContentEnumerator.cs
- DataGridViewColumnCollection.cs
- EditCommandColumn.cs
- LogSwitch.cs
- ReturnType.cs
- ContextMenu.cs
- ListViewItemMouseHoverEvent.cs
- DoubleStorage.cs
- XmlSchemaAll.cs
- AsymmetricKeyExchangeFormatter.cs
- ListBoxChrome.cs
- TextPatternIdentifiers.cs
- StylusSystemGestureEventArgs.cs
- XmlFormatExtensionPrefixAttribute.cs
- UnauthorizedWebPart.cs
- TypeBuilder.cs
- NodeFunctions.cs
- MsmqProcessProtocolHandler.cs
- SpeechRecognizer.cs
- HelloOperation11AsyncResult.cs
- ContractUtils.cs
- DBCSCodePageEncoding.cs
- BamlRecordReader.cs
- Helpers.cs
- SchemaImporterExtension.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- UserPreference.cs
- CodeIdentifier.cs
- DeadCharTextComposition.cs
- NamedPipeHostedTransportConfiguration.cs
- DateTimeFormat.cs
- ConfigurationValues.cs
- ToolstripProfessionalRenderer.cs
- AppDomainAttributes.cs
- SecurityCriticalDataForSet.cs
- TimeSpanValidator.cs
- FileDialog.cs
- StateManagedCollection.cs
- StringUtil.cs
- GradientStop.cs
- NativeActivity.cs
- ErrorFormatterPage.cs
- DebugView.cs
- ClientScriptItem.cs
- TextRangeEdit.cs
- Utils.cs
- RootBrowserWindowProxy.cs
- BrowserDefinitionCollection.cs
- CollectionTraceRecord.cs
- UnsafeNetInfoNativeMethods.cs
- RootAction.cs
- Container.cs
- ReturnEventArgs.cs
- OdbcConnectionString.cs