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
- Vector3DAnimationBase.cs
- ObfuscateAssemblyAttribute.cs
- MeasurementDCInfo.cs
- SystemKeyConverter.cs
- XmlProcessingInstruction.cs
- VisualStyleElement.cs
- StreamInfo.cs
- GeometryHitTestParameters.cs
- HighContrastHelper.cs
- LocationSectionRecord.cs
- CalloutQueueItem.cs
- TypeBuilderInstantiation.cs
- HttpWebResponse.cs
- Point.cs
- QilExpression.cs
- CapabilitiesSection.cs
- SystemDiagnosticsSection.cs
- ListViewSortEventArgs.cs
- ParallelEnumerable.cs
- CodeTypeReference.cs
- DocumentPageView.cs
- MD5.cs
- X509Certificate2.cs
- TextServicesCompartmentContext.cs
- XpsResourcePolicy.cs
- MailWebEventProvider.cs
- DocumentViewerHelper.cs
- GeometryModel3D.cs
- Point.cs
- HttpErrorTraceRecord.cs
- SqlConnectionPoolProviderInfo.cs
- OdbcParameter.cs
- ConfigurationValues.cs
- List.cs
- RewritingSimplifier.cs
- SelectionRangeConverter.cs
- NetSectionGroup.cs
- BaseTemplateBuildProvider.cs
- AppLevelCompilationSectionCache.cs
- AudioDeviceOut.cs
- ContextMenu.cs
- Selector.cs
- recordstate.cs
- TabControlEvent.cs
- DesignerObject.cs
- SqlXmlStorage.cs
- KeyValuePair.cs
- AnimationClock.cs
- XmlCustomFormatter.cs
- BindStream.cs
- TextCharacters.cs
- CompiledIdentityConstraint.cs
- SplitContainer.cs
- Link.cs
- CommandConverter.cs
- EtwTrackingBehavior.cs
- LightweightCodeGenerator.cs
- HttpPostProtocolImporter.cs
- Stack.cs
- AncestorChangedEventArgs.cs
- AddingNewEventArgs.cs
- SettingsPropertyValue.cs
- PickBranch.cs
- ZipIOExtraFieldZip64Element.cs
- GeometryCollection.cs
- StatusBarPanel.cs
- IISMapPath.cs
- HtmlInputText.cs
- XmlEncodedRawTextWriter.cs
- ReadOnlyAttribute.cs
- DictionaryItemsCollection.cs
- RecordConverter.cs
- CodeTypeReferenceCollection.cs
- XmlHierarchicalDataSourceView.cs
- Dump.cs
- ThreadStartException.cs
- panel.cs
- ProcessHostConfigUtils.cs
- IsolatedStorage.cs
- XmlDataCollection.cs
- Send.cs
- TableRowGroup.cs
- JsonFormatReaderGenerator.cs
- HtmlLink.cs
- CalendarTable.cs
- nulltextnavigator.cs
- PropertyValidationContext.cs
- TreeViewImageGenerator.cs
- ElementUtil.cs
- ObjectStateManager.cs
- ParseChildrenAsPropertiesAttribute.cs
- FamilyTypeface.cs
- ConsumerConnectionPointCollection.cs
- AxisAngleRotation3D.cs
- WindowCollection.cs
- SwitchExpression.cs
- DispatcherExceptionFilterEventArgs.cs
- CFStream.cs
- InternalConfigHost.cs
- WebPartsPersonalizationAuthorization.cs