Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ByValueEqualityComparer.cs
- StrokeCollection2.cs
- TransformConverter.cs
- LoginUtil.cs
- ListViewItem.cs
- X509Chain.cs
- UniqueConstraint.cs
- SymLanguageVendor.cs
- DetailsViewDesigner.cs
- ConfigXmlCDataSection.cs
- ProcessModelInfo.cs
- __ComObject.cs
- BufferModesCollection.cs
- ObjectDataSourceDisposingEventArgs.cs
- NotifyParentPropertyAttribute.cs
- WebPartsPersonalization.cs
- ComponentDispatcher.cs
- NotifyCollectionChangedEventArgs.cs
- Animatable.cs
- SmiConnection.cs
- SubordinateTransaction.cs
- DataServices.cs
- RC2CryptoServiceProvider.cs
- DbParameterHelper.cs
- CfgArc.cs
- FlowDocumentFormatter.cs
- DataGridViewCellParsingEventArgs.cs
- PropertyHelper.cs
- DBCommand.cs
- BindingExpressionUncommonField.cs
- EncoderExceptionFallback.cs
- XmlSchemaSimpleContentExtension.cs
- DataSvcMapFileSerializer.cs
- DataServiceRequestException.cs
- PopupEventArgs.cs
- Repeater.cs
- XmlnsDefinitionAttribute.cs
- ComplexType.cs
- DirectoryLocalQuery.cs
- DataSourceGroupCollection.cs
- WindowsListViewGroupHelper.cs
- FragmentQuery.cs
- COM2FontConverter.cs
- WebSysDescriptionAttribute.cs
- BuildDependencySet.cs
- ObjectViewQueryResultData.cs
- IntegerCollectionEditor.cs
- MailDefinition.cs
- SoapServerProtocol.cs
- PathGradientBrush.cs
- PeerNearMe.cs
- ProvidersHelper.cs
- FontClient.cs
- PageWrapper.cs
- PersonalizationAdministration.cs
- PageParser.cs
- OracleBinary.cs
- PageClientProxyGenerator.cs
- FormViewUpdatedEventArgs.cs
- ProxyWebPartConnectionCollection.cs
- DataObjectFieldAttribute.cs
- AffineTransform3D.cs
- XmlSerializationWriter.cs
- PrintDialogDesigner.cs
- RtfFormatStack.cs
- ComPlusInstanceProvider.cs
- DetailsViewCommandEventArgs.cs
- AssociationTypeEmitter.cs
- CodeSubDirectoriesCollection.cs
- MergeEnumerator.cs
- RouteData.cs
- BatchWriter.cs
- ViewEventArgs.cs
- GcSettings.cs
- UnmanagedMarshal.cs
- DiscardableAttribute.cs
- CorrelationKeyCalculator.cs
- DataGridColumnCollection.cs
- DropDownButton.cs
- DrawingState.cs
- SkipStoryboardToFill.cs
- ExecutedRoutedEventArgs.cs
- Decimal.cs
- OneToOneMappingSerializer.cs
- DispatchWrapper.cs
- MappingModelBuildProvider.cs
- FormViewActionList.cs
- WebPartZoneCollection.cs
- WizardForm.cs
- IdleTimeoutMonitor.cs
- MediaPlayer.cs
- SolidBrush.cs
- Emitter.cs
- _ProxyChain.cs
- MemoryRecordBuffer.cs
- EmptyEnumerable.cs
- _BaseOverlappedAsyncResult.cs
- DictionaryGlobals.cs
- WindowsStatic.cs
- ColorDialog.cs