Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- connectionpool.cs
- TextPointer.cs
- ListViewItemSelectionChangedEvent.cs
- HwndKeyboardInputProvider.cs
- CodeGroup.cs
- SQLStringStorage.cs
- RuleRef.cs
- WindowProviderWrapper.cs
- TabControl.cs
- IconHelper.cs
- EntityTypeBase.cs
- DBCommand.cs
- TableLayoutCellPaintEventArgs.cs
- VisualTreeUtils.cs
- ServiceMetadataContractBehavior.cs
- DesignerActionTextItem.cs
- DataBindEngine.cs
- PolyBezierSegment.cs
- JulianCalendar.cs
- Directory.cs
- TemplatedWizardStep.cs
- CreateUserWizard.cs
- DocumentSequenceHighlightLayer.cs
- ConnectionManagementSection.cs
- ProgressBar.cs
- MoveSizeWinEventHandler.cs
- ResourceDefaultValueAttribute.cs
- TextEditorParagraphs.cs
- bidPrivateBase.cs
- AutomationPeer.cs
- View.cs
- DataRowChangeEvent.cs
- PropertyDescriptorComparer.cs
- ButtonField.cs
- HostingPreferredMapPath.cs
- MergablePropertyAttribute.cs
- MetabaseSettingsIis7.cs
- TdsParameterSetter.cs
- SmiEventSink_DeferedProcessing.cs
- MultiPropertyDescriptorGridEntry.cs
- TextServicesDisplayAttributePropertyRanges.cs
- SystemResourceKey.cs
- XmlTextReaderImpl.cs
- ApplicationId.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- NewArrayExpression.cs
- PasswordBox.cs
- CmsUtils.cs
- Vector3DValueSerializer.cs
- XmlILIndex.cs
- ImportCatalogPart.cs
- StopRoutingHandler.cs
- ViewPort3D.cs
- DataGridParentRows.cs
- WsatAdminException.cs
- ViewGenResults.cs
- AddInBase.cs
- ToolBarOverflowPanel.cs
- Run.cs
- ExpandableObjectConverter.cs
- TextEditorSelection.cs
- CodeEventReferenceExpression.cs
- ConfigurationManagerHelper.cs
- CodeNamespaceCollection.cs
- TypeConverterHelper.cs
- ListCollectionView.cs
- FieldToken.cs
- RadioButtonFlatAdapter.cs
- NavigationProgressEventArgs.cs
- PageAdapter.cs
- XPathNavigatorReader.cs
- ConfigXmlWhitespace.cs
- CqlWriter.cs
- ThicknessConverter.cs
- RichTextBoxAutomationPeer.cs
- CharConverter.cs
- ValueSerializerAttribute.cs
- DataBindingCollection.cs
- RemoteWebConfigurationHostStream.cs
- AppDomainAttributes.cs
- XPathExpr.cs
- WorkflowOperationErrorHandler.cs
- Dispatcher.cs
- ContentTextAutomationPeer.cs
- MessageBox.cs
- RadioButtonRenderer.cs
- InternalTypeHelper.cs
- FieldNameLookup.cs
- RtfNavigator.cs
- XPathArrayIterator.cs
- EmptyStringExpandableObjectConverter.cs
- PropertyCondition.cs
- ResXBuildProvider.cs
- MethodSet.cs
- ReadOnlyCollectionBase.cs
- DataGridViewCellMouseEventArgs.cs
- HwndHost.cs
- Helper.cs
- BamlRecordWriter.cs
- SocketInformation.cs