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
- DeclaredTypeElement.cs
- AttributeUsageAttribute.cs
- FontNamesConverter.cs
- Command.cs
- ViewStateChangedEventArgs.cs
- TableColumn.cs
- SQLDecimalStorage.cs
- _AutoWebProxyScriptEngine.cs
- Configuration.cs
- Popup.cs
- TextServicesDisplayAttribute.cs
- Comparer.cs
- ReservationNotFoundException.cs
- AsymmetricSignatureFormatter.cs
- OneOfTypeConst.cs
- ConfigurationValue.cs
- EmbeddedMailObject.cs
- CustomErrorsSectionWrapper.cs
- AnnouncementInnerClient11.cs
- VersionedStreamOwner.cs
- PageRanges.cs
- XAMLParseException.cs
- MutableAssemblyCacheEntry.cs
- AppDomainAttributes.cs
- CheckBoxBaseAdapter.cs
- NullableIntMinMaxAggregationOperator.cs
- ResolveNameEventArgs.cs
- SpecularMaterial.cs
- XamlRtfConverter.cs
- XmlSortKey.cs
- SQLByteStorage.cs
- ServiceOperation.cs
- Baml2006Reader.cs
- EntityWrapperFactory.cs
- RequestResizeEvent.cs
- EntityCommandDefinition.cs
- ConditionalAttribute.cs
- SoapIgnoreAttribute.cs
- TextLine.cs
- UnsafeNativeMethods.cs
- AnnotationHighlightLayer.cs
- RemoteWebConfigurationHost.cs
- ControlIdConverter.cs
- Debug.cs
- HotCommands.cs
- PolyQuadraticBezierSegment.cs
- FacetChecker.cs
- QilChoice.cs
- dbdatarecord.cs
- TraceUtils.cs
- CompletionBookmark.cs
- WindowsAuthenticationEventArgs.cs
- GridEntryCollection.cs
- UnionCodeGroup.cs
- XmlSequenceWriter.cs
- PageCatalogPart.cs
- TextSpan.cs
- PageStatePersister.cs
- JsonXmlDataContract.cs
- DataTableReader.cs
- RedirectionProxy.cs
- Bezier.cs
- GridViewHeaderRowPresenter.cs
- CellLabel.cs
- InternalUserCancelledException.cs
- MatrixTransform3D.cs
- CapabilitiesPattern.cs
- ModelVisual3D.cs
- SoapTypeAttribute.cs
- Function.cs
- TypefaceCollection.cs
- HttpPostProtocolImporter.cs
- VariableQuery.cs
- FontDialog.cs
- ValidationErrorEventArgs.cs
- HttpModuleActionCollection.cs
- BindingManagerDataErrorEventArgs.cs
- Simplifier.cs
- EmbeddedMailObjectsCollection.cs
- CriticalExceptions.cs
- XComponentModel.cs
- PostBackTrigger.cs
- AccessKeyManager.cs
- ExpressionBindingCollection.cs
- unsafenativemethodsother.cs
- HtmlButton.cs
- AppModelKnownContentFactory.cs
- PackageDigitalSignature.cs
- TdsParserSessionPool.cs
- GuidTagList.cs
- FontFamily.cs
- Win32MouseDevice.cs
- Compilation.cs
- DbDataAdapter.cs
- ChannelSinkStacks.cs
- BinaryObjectReader.cs
- TableRow.cs
- RemoteWebConfigurationHostStream.cs
- InputScopeAttribute.cs
- cryptoapiTransform.cs