Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / SafeProcessHandle.cs / 1305600 / 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
- TargetControlTypeCache.cs
- HttpClientCertificate.cs
- LayoutManager.cs
- RijndaelManagedTransform.cs
- RootBrowserWindow.cs
- wgx_render.cs
- DependencyPropertyKey.cs
- PermissionRequestEvidence.cs
- UrlPropertyAttribute.cs
- UnaryExpression.cs
- CmsUtils.cs
- WebPartEditorApplyVerb.cs
- SpeakProgressEventArgs.cs
- DataGridViewCellPaintingEventArgs.cs
- CodeConditionStatement.cs
- CompileXomlTask.cs
- PinnedBufferMemoryStream.cs
- CodeRemoveEventStatement.cs
- NetworkInformationPermission.cs
- WinEventQueueItem.cs
- AnnotationDocumentPaginator.cs
- ClientSponsor.cs
- PermissionSetTriple.cs
- AddInSegmentDirectoryNotFoundException.cs
- IIS7UserPrincipal.cs
- ResourceReader.cs
- CompletedAsyncResult.cs
- NumberAction.cs
- ReliabilityContractAttribute.cs
- MULTI_QI.cs
- UserMapPath.cs
- Propagator.JoinPropagator.cs
- Icon.cs
- ContentIterators.cs
- MouseOverProperty.cs
- KnownColorTable.cs
- UnauthorizedAccessException.cs
- PeerNeighborManager.cs
- infer.cs
- HMACSHA256.cs
- StructuredTypeEmitter.cs
- BufferedWebEventProvider.cs
- HostedHttpTransportManager.cs
- WebUtil.cs
- LiteralSubsegment.cs
- ProviderCommandInfoUtils.cs
- ActivityTypeDesigner.xaml.cs
- _BufferOffsetSize.cs
- PkcsUtils.cs
- ReadOnlyDataSource.cs
- XmlResolver.cs
- EntityExpressionVisitor.cs
- DataTableClearEvent.cs
- TextEffectCollection.cs
- ByteStorage.cs
- MimeTypeMapper.cs
- WebBodyFormatMessageProperty.cs
- EntityChangedParams.cs
- HttpAsyncResult.cs
- BinaryParser.cs
- WebSysDefaultValueAttribute.cs
- EventLogTraceListener.cs
- ObjectItemCollection.cs
- OneOfConst.cs
- IPGlobalProperties.cs
- DecoderNLS.cs
- ResizingMessageFilter.cs
- FontConverter.cs
- XmlIlTypeHelper.cs
- HtmlInputHidden.cs
- GeneralTransform.cs
- HttpFileCollection.cs
- MimeMapping.cs
- CodeMethodReturnStatement.cs
- ActiveDocumentEvent.cs
- NamespaceDisplay.xaml.cs
- PartialArray.cs
- XmlSerializationGeneratedCode.cs
- GridViewCellAutomationPeer.cs
- ReferenceService.cs
- HttpErrorTraceRecord.cs
- DataControlHelper.cs
- CheckedPointers.cs
- XmlDocumentType.cs
- StylusPointPropertyInfoDefaults.cs
- SR.cs
- ParseChildrenAsPropertiesAttribute.cs
- _NTAuthentication.cs
- SecurityChannel.cs
- HttpServerVarsCollection.cs
- StateMachineSubscription.cs
- ListDesigner.cs
- SafeEventLogReadHandle.cs
- ScriptMethodAttribute.cs
- AssemblyBuilderData.cs
- XPathNode.cs
- Label.cs
- Process.cs
- ShapeTypeface.cs
- Formatter.cs