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
- FloaterParaClient.cs
- SingleTagSectionHandler.cs
- RightsManagementUser.cs
- SelectionItemPattern.cs
- DataRecordInternal.cs
- SecurityDescriptor.cs
- TransformPatternIdentifiers.cs
- DateTimeFormatInfo.cs
- ContextMarshalException.cs
- HtmlLink.cs
- UpDownEvent.cs
- BStrWrapper.cs
- PageRequestManager.cs
- GZipStream.cs
- DelegatedStream.cs
- WebPartVerbsEventArgs.cs
- WasHttpModulesInstallComponent.cs
- ToolStripDropDownClosedEventArgs.cs
- EditableRegion.cs
- NativeMethods.cs
- Transform3D.cs
- TextTreeObjectNode.cs
- PlatformNotSupportedException.cs
- TypeRestriction.cs
- ConfigurationElementProperty.cs
- AsymmetricKeyExchangeDeformatter.cs
- DiscreteKeyFrames.cs
- UriScheme.cs
- ModifierKeysConverter.cs
- HtmlTable.cs
- Aggregates.cs
- BinaryUtilClasses.cs
- XPathMultyIterator.cs
- XmlObjectSerializerContext.cs
- ListItem.cs
- SystemThemeKey.cs
- HttpWrapper.cs
- RotationValidation.cs
- UInt64.cs
- AsymmetricAlgorithm.cs
- TypedTableBaseExtensions.cs
- UpdateManifestForBrowserApplication.cs
- WhitespaceRuleLookup.cs
- HttpVersion.cs
- StringFunctions.cs
- DataSourceHelper.cs
- RelatedView.cs
- DataObjectPastingEventArgs.cs
- EntityViewGenerator.cs
- VersionPair.cs
- AnnotationHelper.cs
- SafeRightsManagementQueryHandle.cs
- KeyEventArgs.cs
- COM2Properties.cs
- BrowserTree.cs
- ObjectPropertyMapping.cs
- BaseParser.cs
- StateDesigner.Layouts.cs
- XmlRootAttribute.cs
- AbstractDataSvcMapFileLoader.cs
- UmAlQuraCalendar.cs
- DateTimeConverter2.cs
- RegexWorker.cs
- XPathDocumentIterator.cs
- ConfigurationPropertyAttribute.cs
- SystemColorTracker.cs
- WsdlBuildProvider.cs
- MetadataArtifactLoaderFile.cs
- RawStylusSystemGestureInputReport.cs
- PlatformCulture.cs
- COSERVERINFO.cs
- HtmlTitle.cs
- ToolStripSystemRenderer.cs
- SourceItem.cs
- DataSysAttribute.cs
- SecurityChannelFaultConverter.cs
- RenderingEventArgs.cs
- ToolStripRendererSwitcher.cs
- SystemUnicastIPAddressInformation.cs
- HScrollProperties.cs
- Point3D.cs
- DetectRunnableInstancesTask.cs
- SeekStoryboard.cs
- XmlSecureResolver.cs
- FileDialog_Vista_Interop.cs
- SiblingIterators.cs
- OracleDateTime.cs
- MessageEncodingBindingElement.cs
- AndCondition.cs
- DataMember.cs
- UnmanagedMarshal.cs
- HtmlInputCheckBox.cs
- ProcessThreadCollection.cs
- XhtmlBasicLiteralTextAdapter.cs
- TreeChangeInfo.cs
- MemberAccessException.cs
- FlowPanelDesigner.cs
- RelationshipManager.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- SpecularMaterial.cs