Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / SafeProcessHandle.cs / 1305600 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataSourceXmlElementAttribute.cs
- DataGridRelationshipRow.cs
- SocketPermission.cs
- CorrelationScope.cs
- PanelDesigner.cs
- DataView.cs
- BidOverLoads.cs
- ConsumerConnectionPointCollection.cs
- HostVisual.cs
- SHA256.cs
- WeakReference.cs
- UnicastIPAddressInformationCollection.cs
- TextDecorationUnitValidation.cs
- VariableAction.cs
- PolyLineSegmentFigureLogic.cs
- GroupStyle.cs
- DataGridViewHitTestInfo.cs
- IndicCharClassifier.cs
- NamespaceQuery.cs
- WebPartCatalogAddVerb.cs
- DesignerSerializationOptionsAttribute.cs
- CustomErrorCollection.cs
- ListBox.cs
- SQLMoney.cs
- ResXResourceSet.cs
- TransformDescriptor.cs
- Debugger.cs
- ApplicationId.cs
- ComPlusDiagnosticTraceSchemas.cs
- SQlBooleanStorage.cs
- PriorityBindingExpression.cs
- HostElement.cs
- X509Certificate.cs
- LineInfo.cs
- DynamicMethod.cs
- StoryFragments.cs
- XmlObjectSerializerWriteContext.cs
- TemplateBindingExpressionConverter.cs
- GroupJoinQueryOperator.cs
- PropertyEmitter.cs
- CompilationPass2TaskInternal.cs
- UidManager.cs
- PasswordBoxAutomationPeer.cs
- DragDrop.cs
- Context.cs
- ListView.cs
- PathFigureCollectionConverter.cs
- CountdownEvent.cs
- TrustManagerPromptUI.cs
- XXXInfos.cs
- UpdatePanelTrigger.cs
- AssociationSetEnd.cs
- OleDbPermission.cs
- SpecialNameAttribute.cs
- DiscoveryCallbackBehavior.cs
- ImageIndexConverter.cs
- WaitForChangedResult.cs
- CaseStatementSlot.cs
- CssTextWriter.cs
- EffectiveValueEntry.cs
- Comparer.cs
- UTF32Encoding.cs
- XmlSchemaChoice.cs
- EmissiveMaterial.cs
- SrgsDocument.cs
- BaseDataBoundControl.cs
- ValueType.cs
- FixedSOMImage.cs
- ResourceDisplayNameAttribute.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- ValueExpressions.cs
- GlobalAllocSafeHandle.cs
- SqlWriter.cs
- UnsafeNativeMethods.cs
- Guid.cs
- ReflectionServiceProvider.cs
- safex509handles.cs
- EntityKey.cs
- AnimationClockResource.cs
- GetPageCompletedEventArgs.cs
- InkCanvasInnerCanvas.cs
- ScriptControlManager.cs
- OleDbSchemaGuid.cs
- DummyDataSource.cs
- EntitySetBase.cs
- UdpTransportSettings.cs
- WebPart.cs
- SspiWrapper.cs
- ContextMenu.cs
- ServiceRouteHandler.cs
- RoutedPropertyChangedEventArgs.cs
- FontCacheUtil.cs
- ErrorWrapper.cs
- ProcessHostConfigUtils.cs
- XpsPackagingException.cs
- TypeConverterHelper.cs
- DataViewSetting.cs
- InvalidComObjectException.cs
- ClientScriptItemCollection.cs
- RowUpdatingEventArgs.cs