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
- JsonReaderDelegator.cs
- StatementContext.cs
- Control.cs
- CorrelationManager.cs
- OpenTypeLayout.cs
- GridPatternIdentifiers.cs
- Rule.cs
- CodeTypeReferenceSerializer.cs
- SqlGenerator.cs
- mediaclock.cs
- StringValidatorAttribute.cs
- CellLabel.cs
- SafeNativeHandle.cs
- DataSourceControl.cs
- ZipIOBlockManager.cs
- ListCollectionView.cs
- FrameworkContextData.cs
- TdsParserSessionPool.cs
- XmlText.cs
- ConfigurationStrings.cs
- DataRowCollection.cs
- DebuggerAttributes.cs
- ProxyGenerator.cs
- TextShapeableCharacters.cs
- StrongNameKeyPair.cs
- RemoveStoryboard.cs
- ModelTypeConverter.cs
- ProvidersHelper.cs
- ClientSettingsProvider.cs
- Avt.cs
- MediaCommands.cs
- Column.cs
- EventManager.cs
- BooleanSwitch.cs
- Simplifier.cs
- BitmapSourceSafeMILHandle.cs
- SubqueryTrackingVisitor.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- OdbcReferenceCollection.cs
- Debug.cs
- RawTextInputReport.cs
- SecureStringHasher.cs
- ClientBuildManager.cs
- SByte.cs
- WebConfigurationHostFileChange.cs
- DataGridColumn.cs
- DeleteIndexBinder.cs
- ControlPaint.cs
- Timer.cs
- ProviderUtil.cs
- GeneratedCodeAttribute.cs
- SoapExtensionStream.cs
- SHA256.cs
- IndependentAnimationStorage.cs
- Journaling.cs
- VideoDrawing.cs
- InlinedAggregationOperator.cs
- DataGridViewAutoSizeModeEventArgs.cs
- ColumnResizeAdorner.cs
- CatalogZone.cs
- ParserStreamGeometryContext.cs
- SmtpNetworkElement.cs
- iisPickupDirectory.cs
- TracedNativeMethods.cs
- xmlNames.cs
- DataSetMappper.cs
- CrossContextChannel.cs
- WebPartTransformerAttribute.cs
- BrowserCapabilitiesFactory.cs
- EntityDesignerDataSourceView.cs
- DesigntimeLicenseContext.cs
- ValueTable.cs
- BamlRecordHelper.cs
- CacheEntry.cs
- ImmutableObjectAttribute.cs
- ItemCollection.cs
- DesignerTransaction.cs
- AspCompat.cs
- SpotLight.cs
- ReflectionHelper.cs
- ConfigXmlWhitespace.cs
- EntitySetBaseCollection.cs
- BuildDependencySet.cs
- Converter.cs
- FrameworkElementAutomationPeer.cs
- KeyboardDevice.cs
- BitmapEffectGroup.cs
- Brush.cs
- ProvidePropertyAttribute.cs
- Control.cs
- DocumentViewerConstants.cs
- ZoomComboBox.cs
- DataSetMappper.cs
- RepeaterDataBoundAdapter.cs
- _SslState.cs
- Annotation.cs
- CreateUserWizardDesigner.cs
- XmlSerializerObjectSerializer.cs
- WindowsListBox.cs
- StopRoutingHandler.cs