Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- BehaviorEditorPart.cs
- DescendentsWalker.cs
- IISUnsafeMethods.cs
- EventData.cs
- ObjectStateManagerMetadata.cs
- HttpPostServerProtocol.cs
- _LazyAsyncResult.cs
- InheritanceUI.cs
- HighlightOverlayGlyph.cs
- SqlCommandBuilder.cs
- WorkflowStateRollbackService.cs
- TextAutomationPeer.cs
- WebBrowserHelper.cs
- PanelDesigner.cs
- ProxyManager.cs
- MessageContractExporter.cs
- RenamedEventArgs.cs
- ListViewItemEventArgs.cs
- CollectionChangeEventArgs.cs
- DefaultBindingPropertyAttribute.cs
- RoleServiceManager.cs
- FileDialog_Vista.cs
- ComplexType.cs
- EntityUtil.cs
- AuthorizationPolicyTypeElement.cs
- IsolatedStorageException.cs
- FlatButtonAppearance.cs
- Symbol.cs
- Events.cs
- SimpleType.cs
- DynamicActivityXamlReader.cs
- SystemUdpStatistics.cs
- MouseButton.cs
- InputScopeAttribute.cs
- DBSqlParserColumnCollection.cs
- Msmq4PoisonHandler.cs
- RegexMatchCollection.cs
- MessageFilter.cs
- _SSPIWrapper.cs
- SuppressMessageAttribute.cs
- UIElement.cs
- BitmapEffectDrawing.cs
- WriterOutput.cs
- UrlAuthorizationModule.cs
- returneventsaver.cs
- BooleanExpr.cs
- DataProviderNameConverter.cs
- IsolationInterop.cs
- OperationInvokerBehavior.cs
- SrgsToken.cs
- DataGridViewRowCancelEventArgs.cs
- DodSequenceMerge.cs
- BinaryUtilClasses.cs
- WrappingXamlSchemaContext.cs
- Vars.cs
- PrimitiveXmlSerializers.cs
- RowTypeElement.cs
- ResourcePool.cs
- AsyncOperation.cs
- PersonalizationProviderCollection.cs
- basecomparevalidator.cs
- XmlValidatingReader.cs
- RequestBringIntoViewEventArgs.cs
- SettingsAttributes.cs
- TextRange.cs
- RegisteredExpandoAttribute.cs
- SqlCaseSimplifier.cs
- DataGridViewIntLinkedList.cs
- IndexedString.cs
- MbpInfo.cs
- NoneExcludedImageIndexConverter.cs
- LicenseContext.cs
- X509SecurityTokenParameters.cs
- ReachDocumentPageSerializerAsync.cs
- ResourcePermissionBaseEntry.cs
- LocalizationComments.cs
- loginstatus.cs
- HtmlToClrEventProxy.cs
- listitem.cs
- CollectionsUtil.cs
- DependencyPropertyKind.cs
- StatusStrip.cs
- ListBoxItem.cs
- Win32KeyboardDevice.cs
- HealthMonitoringSection.cs
- BinHexEncoder.cs
- LineServicesRun.cs
- WebEvents.cs
- ImpersonationContext.cs
- PartialTrustVisibleAssemblyCollection.cs
- WebContext.cs
- Stylus.cs
- FormsIdentity.cs
- DataTablePropertyDescriptor.cs
- PeerCollaborationPermission.cs
- BoolLiteral.cs
- Vector.cs
- WebConfigurationHost.cs
- DataTableReaderListener.cs
- ActionMessageFilter.cs