Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / SafeProcessHandle.cs / 1 / SafeProcessHandle.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // // History: // 10/04/2003 : [....] Created //--------------------------------------------------------------------------- // PRESHARP: In order to avoid generating warnings about unkown message numbers and unknown pragmas. #pragma warning disable 1634, 1691 using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Windows.Automation; using Microsoft.Win32.SafeHandles; using MS.Win32; namespace MS.Internal.Automation { internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { // This constructor is used by the P/Invoke marshaling layer // to allocate a SafeHandle instance. P/Invoke then does the // appropriate method call, storing the handle in this class. private SafeProcessHandle() : base(true) {} internal SafeProcessHandle(NativeMethods.HWND hwnd) : base(true) { int processId; // Get process id... // GetWindowThreadProcessId does use SetLastError(). So a call to GetLastError() would be meanless. // Disabling the PreSharp warning. #pragma warning suppress 6523 if (SafeNativeMethods.GetWindowThreadProcessId(hwnd, out processId) == 0) { throw new ElementNotAvailableException(); } SetHandle(Misc.OpenProcess(UnsafeNativeMethods.PROCESS_QUERY_INFORMATION | UnsafeNativeMethods.PROCESS_VM_READ, false, processId, hwnd)); } // protected override bool ReleaseHandle() { return Misc.CloseHandle(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: // // History: // 10/04/2003 : [....] Created //--------------------------------------------------------------------------- // PRESHARP: In order to avoid generating warnings about unkown message numbers and unknown pragmas. #pragma warning disable 1634, 1691 using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Windows.Automation; using Microsoft.Win32.SafeHandles; using MS.Win32; namespace MS.Internal.Automation { internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { // This constructor is used by the P/Invoke marshaling layer // to allocate a SafeHandle instance. P/Invoke then does the // appropriate method call, storing the handle in this class. private SafeProcessHandle() : base(true) {} internal SafeProcessHandle(NativeMethods.HWND hwnd) : base(true) { int processId; // Get process id... // GetWindowThreadProcessId does use SetLastError(). So a call to GetLastError() would be meanless. // Disabling the PreSharp warning. #pragma warning suppress 6523 if (SafeNativeMethods.GetWindowThreadProcessId(hwnd, out processId) == 0) { throw new ElementNotAvailableException(); } SetHandle(Misc.OpenProcess(UnsafeNativeMethods.PROCESS_QUERY_INFORMATION | UnsafeNativeMethods.PROCESS_VM_READ, false, processId, hwnd)); } // protected override bool ReleaseHandle() { return Misc.CloseHandle(handle); } } } // 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
- EnvironmentPermission.cs
- ToolStripTextBox.cs
- FormatException.cs
- Int32Collection.cs
- DiagnosticsConfiguration.cs
- FrameDimension.cs
- PropertyTab.cs
- NullableBoolConverter.cs
- SafeViewOfFileHandle.cs
- DocumentOrderComparer.cs
- ProfileWorkflowElement.cs
- path.cs
- DiscoveryServerProtocol.cs
- CodeArrayIndexerExpression.cs
- ExpandableObjectConverter.cs
- WindowsPrincipal.cs
- RelationshipWrapper.cs
- CharacterHit.cs
- Win32KeyboardDevice.cs
- EntityTypeEmitter.cs
- DeclaredTypeElement.cs
- SynchronizedDispatch.cs
- DebugInfoGenerator.cs
- LocatorManager.cs
- FormsAuthenticationUser.cs
- StrongNameHelpers.cs
- DrawingAttributes.cs
- RectValueSerializer.cs
- DelegatingTypeDescriptionProvider.cs
- GenericEnumConverter.cs
- Triplet.cs
- externdll.cs
- WebPartManager.cs
- TextPointer.cs
- PropertyExpression.cs
- FontConverter.cs
- SectionInput.cs
- FixedSOMTableRow.cs
- SslStream.cs
- DoubleUtil.cs
- TdsParameterSetter.cs
- SpecialNameAttribute.cs
- InternalConfigHost.cs
- ExtensionWindowResizeGrip.cs
- SQLDateTimeStorage.cs
- CollectionView.cs
- ConfigurationPermission.cs
- Brush.cs
- DesignBindingPropertyDescriptor.cs
- IteratorFilter.cs
- ImageAnimator.cs
- WebPartMenuStyle.cs
- DataMisalignedException.cs
- HostProtectionException.cs
- StringOutput.cs
- FacetValues.cs
- GradientStop.cs
- AspProxy.cs
- StoreAnnotationsMap.cs
- linebase.cs
- OleDbReferenceCollection.cs
- COM2ExtendedTypeConverter.cs
- ContentPresenter.cs
- DependencyObject.cs
- SystemPens.cs
- SqlSelectClauseBuilder.cs
- WebPartCancelEventArgs.cs
- BoundPropertyEntry.cs
- HttpModuleAction.cs
- HttpHeaderCollection.cs
- BeginEvent.cs
- BitmapCache.cs
- ResourceExpression.cs
- WebColorConverter.cs
- Code.cs
- CopyNamespacesAction.cs
- XmlArrayAttribute.cs
- ErrorRuntimeConfig.cs
- EncodingInfo.cs
- ScriptComponentDescriptor.cs
- PointAnimationClockResource.cs
- FormViewUpdatedEventArgs.cs
- FixedSOMLineRanges.cs
- GPRECTF.cs
- TCEAdapterGenerator.cs
- DataKeyArray.cs
- ThreadPool.cs
- TriState.cs
- CalendarData.cs
- __Filters.cs
- DoWhileDesigner.xaml.cs
- ListViewGroupConverter.cs
- SafeRegistryHandle.cs
- UnauthorizedWebPart.cs
- CurrencyManager.cs
- precedingquery.cs
- ClientData.cs
- MatrixAnimationUsingKeyFrames.cs
- ScriptRegistrationManager.cs
- UpDownEvent.cs