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
- HttpCookiesSection.cs
- ConfigurationHandlersInstallComponent.cs
- ProfileSettings.cs
- PolyBezierSegmentFigureLogic.cs
- XmlHierarchyData.cs
- TransactionManager.cs
- XmlWrappingReader.cs
- HttpHandlerAction.cs
- XmlBinaryReaderSession.cs
- UserControlParser.cs
- ElementMarkupObject.cs
- CodeGen.cs
- ValueConversionAttribute.cs
- ParseNumbers.cs
- PinnedBufferMemoryStream.cs
- X509CertificateTokenFactoryCredential.cs
- XmlCharacterData.cs
- SoapMessage.cs
- SessionParameter.cs
- Compilation.cs
- BitmapPalette.cs
- BoundPropertyEntry.cs
- TemplateComponentConnector.cs
- IIS7WorkerRequest.cs
- DirtyTextRange.cs
- Header.cs
- X509Certificate2Collection.cs
- StringCollectionMarkupSerializer.cs
- PrimaryKeyTypeConverter.cs
- CodeObject.cs
- PropertyTabAttribute.cs
- FamilyCollection.cs
- ImageSource.cs
- Automation.cs
- DataGridViewTextBoxEditingControl.cs
- RightsManagementEncryptionTransform.cs
- CodeAttributeArgument.cs
- DynamicResourceExtension.cs
- Menu.cs
- DirectoryNotFoundException.cs
- DispatcherFrame.cs
- FieldNameLookup.cs
- TypefaceMetricsCache.cs
- DetailsViewDeleteEventArgs.cs
- OleDbReferenceCollection.cs
- InstanceContext.cs
- ObjectDataSource.cs
- MergeLocalizationDirectives.cs
- ApplicationSecurityInfo.cs
- RegisteredExpandoAttribute.cs
- WorkflowInstance.cs
- RepeaterItemEventArgs.cs
- EventLogInformation.cs
- GeneralTransform3DGroup.cs
- WindowsSolidBrush.cs
- RadioButton.cs
- Material.cs
- WebPartMovingEventArgs.cs
- Operator.cs
- GACIdentityPermission.cs
- XMLSyntaxException.cs
- MemoryMappedViewAccessor.cs
- DetailsViewRowCollection.cs
- DataListItemCollection.cs
- TreeViewItemAutomationPeer.cs
- ConfigurationPropertyCollection.cs
- HttpProcessUtility.cs
- HtmlInputFile.cs
- EntityProviderServices.cs
- BaseAutoFormat.cs
- PropertyGrid.cs
- LinearGradientBrush.cs
- EndpointAddressProcessor.cs
- CharacterHit.cs
- OracleException.cs
- AuthorizationRule.cs
- UnsafeNativeMethods.cs
- PersonalizableTypeEntry.cs
- ProviderBase.cs
- EmptyCollection.cs
- MetaForeignKeyColumn.cs
- DecimalSumAggregationOperator.cs
- HwndSourceParameters.cs
- BuildResultCache.cs
- WebEvents.cs
- RowParagraph.cs
- ColumnBinding.cs
- RepeaterItemCollection.cs
- DataGridViewImageColumn.cs
- ToolStripContentPanelRenderEventArgs.cs
- QilVisitor.cs
- Validator.cs
- ProxyManager.cs
- Padding.cs
- TextTrailingWordEllipsis.cs
- FormsAuthenticationTicket.cs
- EventLogTraceListener.cs
- FixedSOMSemanticBox.cs
- XPathQilFactory.cs
- SystemWebSectionGroup.cs