Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListBox.cs
- AttributeQuery.cs
- RSACryptoServiceProvider.cs
- TextPointerBase.cs
- SqlCacheDependencyDatabase.cs
- Grant.cs
- MappingSource.cs
- TypeUtil.cs
- ComponentResourceKey.cs
- InvalidCardException.cs
- TypeExtension.cs
- EtwTrackingParticipant.cs
- Matrix3DStack.cs
- MILUtilities.cs
- AdornerPresentationContext.cs
- xml.cs
- ListBoxItem.cs
- TreeViewImageKeyConverter.cs
- ListViewEditEventArgs.cs
- DesignerToolboxInfo.cs
- HtmlInputFile.cs
- CultureInfoConverter.cs
- ScrollProviderWrapper.cs
- TextRenderingModeValidation.cs
- TrackingValidationObjectDictionary.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- IOException.cs
- SafeProcessHandle.cs
- RtfFormatStack.cs
- UnhandledExceptionEventArgs.cs
- XmlSchema.cs
- SymbolEqualComparer.cs
- ServiceReference.cs
- TextBlockAutomationPeer.cs
- StringToken.cs
- ToolStripProgressBar.cs
- WebPartMinimizeVerb.cs
- CellQuery.cs
- SamlConditions.cs
- Models.cs
- WebBrowser.cs
- RequiredFieldValidator.cs
- ZipIOExtraField.cs
- COSERVERINFO.cs
- FullTextLine.cs
- AccessibleObject.cs
- SvcMapFileSerializer.cs
- SetIterators.cs
- ProbeDuplex11AsyncResult.cs
- ThicknessConverter.cs
- ToolStripPanelDesigner.cs
- EmbeddedObject.cs
- ReflectionUtil.cs
- DiffuseMaterial.cs
- Propagator.Evaluator.cs
- ArraySegment.cs
- InvokeCompletedEventArgs.cs
- ListDictionaryInternal.cs
- ExceptionAggregator.cs
- UnmanagedMarshal.cs
- bidPrivateBase.cs
- FileDataSourceCache.cs
- ViewRendering.cs
- CommentEmitter.cs
- TextServicesLoader.cs
- ToolStripMenuItem.cs
- SecurityResources.cs
- TouchPoint.cs
- FileAuthorizationModule.cs
- MachineKeySection.cs
- BypassElementCollection.cs
- BuildManagerHost.cs
- ArrangedElementCollection.cs
- EventMemberCodeDomSerializer.cs
- TextEndOfSegment.cs
- BuildProviderCollection.cs
- Geometry3D.cs
- LoadWorkflowByInstanceKeyCommand.cs
- TreeNodeSelectionProcessor.cs
- TransformPattern.cs
- SubMenuStyle.cs
- _ShellExpression.cs
- XsdDateTime.cs
- NativeWindow.cs
- DesignConnectionCollection.cs
- Compiler.cs
- DataGridBoundColumn.cs
- XmlSchemaAppInfo.cs
- IIS7UserPrincipal.cs
- SslStream.cs
- PropertyDescriptorComparer.cs
- DecoderNLS.cs
- SqlConnectionHelper.cs
- MachineKeySection.cs
- Int64Converter.cs
- ListControlActionList.cs
- ObjectPropertyMapping.cs
- IPGlobalProperties.cs
- URL.cs
- Int16Animation.cs