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
- Merger.cs
- CompositeKey.cs
- FormattedTextSymbols.cs
- SafeFileMappingHandle.cs
- DiscoveryCallbackBehavior.cs
- LoginName.cs
- TableRow.cs
- BrowserCapabilitiesFactory.cs
- FileDialogCustomPlace.cs
- __ConsoleStream.cs
- StdValidatorsAndConverters.cs
- ColorContext.cs
- TranslateTransform.cs
- SamlSubjectStatement.cs
- DataGridAddNewRow.cs
- PathNode.cs
- Stack.cs
- DSASignatureDeformatter.cs
- CatalogPartCollection.cs
- GridViewItemAutomationPeer.cs
- SchemaType.cs
- DataRecordInfo.cs
- SpotLight.cs
- OneOf.cs
- XPathSingletonIterator.cs
- HttpServerVarsCollection.cs
- ResourceCollectionInfo.cs
- ContextBase.cs
- AuthorizationRuleCollection.cs
- DataGridCellAutomationPeer.cs
- UnsafeNativeMethodsMilCoreApi.cs
- HitTestFilterBehavior.cs
- InvalidEnumArgumentException.cs
- ServiceOperation.cs
- DbProviderFactory.cs
- FunctionQuery.cs
- PagerStyle.cs
- InputProcessorProfilesLoader.cs
- BaseContextMenu.cs
- ProtocolViolationException.cs
- RepeatBehaviorConverter.cs
- XmlSerializerVersionAttribute.cs
- ArraySet.cs
- DecoderNLS.cs
- TextLine.cs
- DataGridCaption.cs
- MessageTransmitTraceRecord.cs
- Point3DConverter.cs
- DesignerActionVerbList.cs
- NullableConverter.cs
- AnimationTimeline.cs
- SocketInformation.cs
- InvalidDataException.cs
- AutomationEventArgs.cs
- XmlDataSourceView.cs
- NumberFormatter.cs
- Vector3dCollection.cs
- NumberSubstitution.cs
- WebPartZoneCollection.cs
- BitmapData.cs
- DataKeyArray.cs
- BaseCollection.cs
- ResXResourceWriter.cs
- ActivityStatusChangeEventArgs.cs
- ServiceHost.cs
- QilStrConcatenator.cs
- TreeViewAutomationPeer.cs
- Point4D.cs
- GenericAuthenticationEventArgs.cs
- FileDialogCustomPlaces.cs
- TextSelectionHighlightLayer.cs
- AttachedPropertyDescriptor.cs
- GeneralTransformGroup.cs
- HttpModuleAction.cs
- DependencySource.cs
- HyperLinkDataBindingHandler.cs
- HwndStylusInputProvider.cs
- SafeArrayTypeMismatchException.cs
- SR.Designer.cs
- QueryTask.cs
- Socket.cs
- MenuItem.cs
- Sequence.cs
- TypeGeneratedEventArgs.cs
- SqlDelegatedTransaction.cs
- FileStream.cs
- BitmapCache.cs
- SoapObjectReader.cs
- SettingsBase.cs
- SqlParameter.cs
- PolicyException.cs
- NativeCppClassAttribute.cs
- Util.cs
- WSHttpBindingCollectionElement.cs
- DataGridViewColumnHeaderCell.cs
- IndexingContentUnit.cs
- ConvertersCollection.cs
- ObjectDataSourceFilteringEventArgs.cs
- RepeaterItemEventArgs.cs
- SafeEventLogWriteHandle.cs