Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- SvcMapFile.cs
- LicenseException.cs
- JapaneseCalendar.cs
- FlowPanelDesigner.cs
- MapPathBasedVirtualPathProvider.cs
- NegatedConstant.cs
- ParserContext.cs
- SizeValueSerializer.cs
- PointCollectionConverter.cs
- CodeAttributeArgumentCollection.cs
- ToolStripItemTextRenderEventArgs.cs
- WorkflowServiceInstance.cs
- QueryHandler.cs
- MemberRelationshipService.cs
- Animatable.cs
- RoutedUICommand.cs
- Hashtable.cs
- streamingZipPartStream.cs
- PasswordPropertyTextAttribute.cs
- AssemblySettingAttributes.cs
- SplitContainer.cs
- ChainOfDependencies.cs
- GeometryGroup.cs
- KeyboardNavigation.cs
- XmlTextReaderImpl.cs
- RemoteWebConfigurationHost.cs
- FamilyMap.cs
- ViewSimplifier.cs
- ServiceInstallComponent.cs
- MessageLogTraceRecord.cs
- HtmlControl.cs
- InfoCard.cs
- Columns.cs
- DataRelationPropertyDescriptor.cs
- PublisherIdentityPermission.cs
- SystemParameters.cs
- TableSectionStyle.cs
- UndirectedGraph.cs
- SqlCacheDependencyDatabase.cs
- Condition.cs
- Stack.cs
- FontNameEditor.cs
- ToolStripDropDownClosedEventArgs.cs
- DSGeneratorProblem.cs
- HostAdapter.cs
- ByteAnimationUsingKeyFrames.cs
- RelationshipWrapper.cs
- CqlWriter.cs
- ActivationServices.cs
- BridgeDataReader.cs
- DbModificationCommandTree.cs
- SBCSCodePageEncoding.cs
- Underline.cs
- SpellCheck.cs
- KeySplineConverter.cs
- TcpConnectionPoolSettings.cs
- PriorityQueue.cs
- InternalTypeHelper.cs
- CurrencyWrapper.cs
- MultipleViewPattern.cs
- ApplicationActivator.cs
- LineGeometry.cs
- ProcessModelInfo.cs
- AutoGeneratedField.cs
- CacheDict.cs
- CreateParams.cs
- AdditionalEntityFunctions.cs
- DocumentCollection.cs
- MetadataSerializer.cs
- XmlAttribute.cs
- PrtCap_Reader.cs
- MetafileHeaderEmf.cs
- CreateParams.cs
- OdbcStatementHandle.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- DataGridColumn.cs
- InputReport.cs
- SHA256.cs
- PageContent.cs
- DoubleUtil.cs
- EntityStoreSchemaFilterEntry.cs
- SecurityContextTokenCache.cs
- GcSettings.cs
- WindowsImpersonationContext.cs
- FileSecurity.cs
- BindingsCollection.cs
- Error.cs
- ParseElementCollection.cs
- RepeatBehaviorConverter.cs
- WorkflowMessageEventArgs.cs
- WebPartTransformer.cs
- PKCS1MaskGenerationMethod.cs
- HttpRawResponse.cs
- Stream.cs
- SmtpReplyReaderFactory.cs
- TimeSpanValidator.cs
- DeflateStream.cs
- MimeMapping.cs
- MenuCommand.cs
- MaskInputRejectedEventArgs.cs