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
- PeerNearMe.cs
- SamlSecurityToken.cs
- TableFieldsEditor.cs
- SystemWebCachingSectionGroup.cs
- UrlAuthFailedErrorFormatter.cs
- PersonalizationState.cs
- DaylightTime.cs
- ThicknessAnimation.cs
- PageDeviceFont.cs
- srgsitem.cs
- LineMetrics.cs
- webclient.cs
- DesignerSerializationOptionsAttribute.cs
- BoundingRectTracker.cs
- DbConnectionFactory.cs
- AccessDataSourceView.cs
- PolicyLevel.cs
- DataGridViewCellCollection.cs
- DiagnosticTraceSchemas.cs
- SettingsSection.cs
- ResXBuildProvider.cs
- WebBrowsableAttribute.cs
- AccessControlList.cs
- HelpFileFileNameEditor.cs
- CodeNamespaceImportCollection.cs
- IgnorePropertiesAttribute.cs
- ColorConverter.cs
- RemoteWebConfigurationHostServer.cs
- LayoutEngine.cs
- TableItemStyle.cs
- ParserStreamGeometryContext.cs
- ComponentDispatcher.cs
- SystemTcpStatistics.cs
- ContentControl.cs
- SafeLibraryHandle.cs
- Comparer.cs
- DependencyPropertyAttribute.cs
- CurrencyWrapper.cs
- UnSafeCharBuffer.cs
- DependentList.cs
- DescendantOverDescendantQuery.cs
- DbConnectionPoolCounters.cs
- Point3DCollection.cs
- DataSet.cs
- Brush.cs
- AsyncDataRequest.cs
- ByteStreamGeometryContext.cs
- TabPage.cs
- TranslateTransform3D.cs
- smtpconnection.cs
- URLIdentityPermission.cs
- InvalidMessageContractException.cs
- PropertySet.cs
- ZoomingMessageFilter.cs
- RangeValidator.cs
- LogConverter.cs
- WmlTextViewAdapter.cs
- UnmanagedMemoryStreamWrapper.cs
- HostedTcpTransportManager.cs
- SafeCertificateContext.cs
- WebUtil.cs
- DefaultValueTypeConverter.cs
- IApplicationTrustManager.cs
- WebBrowsableAttribute.cs
- ReadContentAsBinaryHelper.cs
- CultureInfo.cs
- XmlValidatingReaderImpl.cs
- MiniMapControl.xaml.cs
- EntityCommandCompilationException.cs
- coordinatorscratchpad.cs
- PersonalizationState.cs
- CollectionViewGroup.cs
- QuaternionRotation3D.cs
- TargetControlTypeCache.cs
- Animatable.cs
- ChildrenQuery.cs
- StringUtil.cs
- WSHttpBindingBase.cs
- MarshalDirectiveException.cs
- ComponentResourceKeyConverter.cs
- PropertyPath.cs
- IdleTimeoutMonitor.cs
- CodeVariableDeclarationStatement.cs
- XamlBrushSerializer.cs
- SerializationObjectManager.cs
- CfgSemanticTag.cs
- IdentityHolder.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- ConstructorNeedsTagAttribute.cs
- EntityContainer.cs
- IntegerValidator.cs
- ReflectPropertyDescriptor.cs
- QuestionEventArgs.cs
- Matrix3D.cs
- ListItemParagraph.cs
- CharacterString.cs
- SchemaObjectWriter.cs
- RowToParametersTransformer.cs
- ImageCreator.cs
- HttpProfileGroupBase.cs