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
- _NestedSingleAsyncResult.cs
- _AcceptOverlappedAsyncResult.cs
- Scalars.cs
- RadioButton.cs
- ActionItem.cs
- HealthMonitoringSection.cs
- ObjectSet.cs
- ObjectCloneHelper.cs
- EditBehavior.cs
- FixUpCollection.cs
- SamlNameIdentifierClaimResource.cs
- ListViewItem.cs
- DataRow.cs
- AssemblyAttributesGoHere.cs
- _SingleItemRequestCache.cs
- ItemDragEvent.cs
- MethodImplAttribute.cs
- InvocationExpression.cs
- WSSecurityOneDotZeroReceiveSecurityHeader.cs
- SystemUnicastIPAddressInformation.cs
- PeerCollaborationPermission.cs
- AccessedThroughPropertyAttribute.cs
- DataTableTypeConverter.cs
- Compiler.cs
- BooleanProjectedSlot.cs
- IssuanceLicense.cs
- SoapReflector.cs
- CheckBoxFlatAdapter.cs
- Selector.cs
- coordinatorfactory.cs
- ObjectDataSourceMethodEventArgs.cs
- MatrixAnimationUsingPath.cs
- ParallelDesigner.cs
- AssemblyCache.cs
- thaishape.cs
- NextPreviousPagerField.cs
- CacheDependency.cs
- AccessControlList.cs
- TextSchema.cs
- AppearanceEditorPart.cs
- SymbolPair.cs
- ReadOnlyNameValueCollection.cs
- TimeEnumHelper.cs
- DataGridViewRowConverter.cs
- RangeValueProviderWrapper.cs
- XmlComment.cs
- ContentFilePart.cs
- DynamicObject.cs
- DataGridViewCellPaintingEventArgs.cs
- SourceInterpreter.cs
- RegularExpressionValidator.cs
- ArraySubsetEnumerator.cs
- Command.cs
- WebDisplayNameAttribute.cs
- LocatorPartList.cs
- PointKeyFrameCollection.cs
- MeasureData.cs
- AllMembershipCondition.cs
- Process.cs
- GraphicsPathIterator.cs
- MouseGestureValueSerializer.cs
- ErrorStyle.cs
- ReadOnlyAttribute.cs
- QilReference.cs
- CharacterMetrics.cs
- NavigationPropertyEmitter.cs
- AttributeSetAction.cs
- FilteredDataSetHelper.cs
- FileRecordSequenceCompletedAsyncResult.cs
- ColorTransform.cs
- CodeAttachEventStatement.cs
- Crypto.cs
- HandledEventArgs.cs
- XmlDataSourceNodeDescriptor.cs
- EntityChangedParams.cs
- xmlsaver.cs
- TypePresenter.xaml.cs
- BufferModesCollection.cs
- OrderingQueryOperator.cs
- SEHException.cs
- PropertyGridEditorPart.cs
- CardSpaceSelector.cs
- WebPartEditVerb.cs
- SerializationSectionGroup.cs
- CodeDomExtensionMethods.cs
- EventDriven.cs
- ToolBar.cs
- DrawingBrush.cs
- CharStorage.cs
- GenericTypeParameterBuilder.cs
- XsdDuration.cs
- MobileControlsSectionHelper.cs
- LoadGrammarCompletedEventArgs.cs
- Typography.cs
- PriorityQueue.cs
- RegisteredDisposeScript.cs
- HwndStylusInputProvider.cs
- ActivationServices.cs
- TabControl.cs
- TextEditorThreadLocalStore.cs