Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProtocolElementCollection.cs
- ColorDialog.cs
- objectresult_tresulttype.cs
- TextLineResult.cs
- DragCompletedEventArgs.cs
- GCHandleCookieTable.cs
- MatrixIndependentAnimationStorage.cs
- StreamWithDictionary.cs
- LinqDataSourceDeleteEventArgs.cs
- HtmlAnchor.cs
- WebConfigManager.cs
- PropertyConverter.cs
- PersistenceTypeAttribute.cs
- Math.cs
- DataGridCellClipboardEventArgs.cs
- ItemList.cs
- RootProfilePropertySettingsCollection.cs
- _DisconnectOverlappedAsyncResult.cs
- CustomAttributeSerializer.cs
- PageBreakRecord.cs
- BooleanFunctions.cs
- SemanticAnalyzer.cs
- _Events.cs
- ToolStripLocationCancelEventArgs.cs
- TraceListener.cs
- BrushMappingModeValidation.cs
- SafeRegistryHandle.cs
- SynchronizedInputAdaptor.cs
- XsltLibrary.cs
- PageCache.cs
- TreeNodeCollection.cs
- EnumValAlphaComparer.cs
- _FixedSizeReader.cs
- NavigatorOutput.cs
- XmlMapping.cs
- RepeatBehavior.cs
- EditBehavior.cs
- WrappedReader.cs
- IPHostEntry.cs
- CommandExpr.cs
- _TimerThread.cs
- FilterEventArgs.cs
- RefExpr.cs
- GeneratedCodeAttribute.cs
- PartitionerQueryOperator.cs
- Brush.cs
- MasterPage.cs
- _ProxyRegBlob.cs
- safesecurityhelperavalon.cs
- NullRuntimeConfig.cs
- TogglePattern.cs
- ObjectViewListener.cs
- VSWCFServiceContractGenerator.cs
- PropertyBuilder.cs
- XhtmlBasicListAdapter.cs
- XamlFilter.cs
- bidPrivateBase.cs
- ProtectedConfigurationSection.cs
- AsyncStreamReader.cs
- COM2TypeInfoProcessor.cs
- ProcessModelSection.cs
- RequestSecurityToken.cs
- LinqDataSourceInsertEventArgs.cs
- SqlUserDefinedAggregateAttribute.cs
- SoapIncludeAttribute.cs
- RelatedCurrencyManager.cs
- AssociationSetEnd.cs
- ProxyFragment.cs
- HttpRequestWrapper.cs
- CompilerWrapper.cs
- StringPropertyBuilder.cs
- AttributeAction.cs
- SelectionRangeConverter.cs
- OdbcDataReader.cs
- MethodImplAttribute.cs
- UnsettableComboBox.cs
- FreezableCollection.cs
- PermissionSet.cs
- DataBindEngine.cs
- InfoCardClaimCollection.cs
- SessionParameter.cs
- UniqueConstraint.cs
- TextAnchor.cs
- AttributeQuery.cs
- TransformConverter.cs
- storepermissionattribute.cs
- TheQuery.cs
- IPAddress.cs
- ExpressionBindings.cs
- Publisher.cs
- AddInBase.cs
- BitmapEffectDrawing.cs
- InstanceKeyNotReadyException.cs
- BaseDataList.cs
- InlinedAggregationOperatorEnumerator.cs
- ContextMenuStripActionList.cs
- TraceContextRecord.cs
- IOThreadTimer.cs
- RightNameExpirationInfoPair.cs
- WindowsListViewGroupSubsetLink.cs