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
- TimeSpan.cs
- NCryptNative.cs
- FactoryMaker.cs
- DataGridColumn.cs
- Viewport2DVisual3D.cs
- ToggleProviderWrapper.cs
- SaveFileDialog.cs
- Transform3D.cs
- CustomErrorsSection.cs
- RecordBuilder.cs
- WaitHandleCannotBeOpenedException.cs
- MouseActionConverter.cs
- FlowDocumentFormatter.cs
- CustomCredentialPolicy.cs
- HtmlButton.cs
- ComAwareEventInfo.cs
- VectorAnimationBase.cs
- CodeComment.cs
- VirtualPathProvider.cs
- AttributeCollection.cs
- RegexCompilationInfo.cs
- ApplicationManager.cs
- TemplatedWizardStep.cs
- Knowncolors.cs
- ComplexTypeEmitter.cs
- HitTestWithPointDrawingContextWalker.cs
- AsyncOperationContext.cs
- ResourceExpression.cs
- FixedPageStructure.cs
- ScrollChrome.cs
- XmlAutoDetectWriter.cs
- ClientConvert.cs
- assertwrapper.cs
- JsonByteArrayDataContract.cs
- PageHandlerFactory.cs
- SchemaDeclBase.cs
- SqlCacheDependencyDatabaseCollection.cs
- MonitorWrapper.cs
- StorageMappingItemCollection.cs
- XsltContext.cs
- Vertex.cs
- SourceItem.cs
- StructureChangedEventArgs.cs
- Region.cs
- ParentQuery.cs
- PageParser.cs
- GridView.cs
- PropertyNames.cs
- FileIOPermission.cs
- Container.cs
- TypeBrowserDialog.cs
- EdgeProfileValidation.cs
- log.cs
- StagingAreaInputItem.cs
- StaticResourceExtension.cs
- HelpPage.cs
- OdbcReferenceCollection.cs
- ConnectionInterfaceCollection.cs
- SqlNotificationRequest.cs
- InfoCardSymmetricCrypto.cs
- TCEAdapterGenerator.cs
- MembershipSection.cs
- PassportAuthenticationModule.cs
- coordinator.cs
- TextSerializer.cs
- DataFieldEditor.cs
- XpsDigitalSignature.cs
- QilPatternFactory.cs
- FontStyleConverter.cs
- SafeCryptoHandles.cs
- NonVisualControlAttribute.cs
- Transform.cs
- querybuilder.cs
- TrustManagerMoreInformation.cs
- WebBrowsableAttribute.cs
- GroupBoxRenderer.cs
- IDQuery.cs
- SessionEndingCancelEventArgs.cs
- PlatformCulture.cs
- Link.cs
- AttachedAnnotationChangedEventArgs.cs
- QilFunction.cs
- ConfigurationManager.cs
- CoreSwitches.cs
- BuildResultCache.cs
- WmfPlaceableFileHeader.cs
- NetStream.cs
- WebColorConverter.cs
- TableParagraph.cs
- ProfileEventArgs.cs
- DecimalAnimation.cs
- UrlAuthorizationModule.cs
- FileUtil.cs
- DbProviderServices.cs
- AsyncSerializedWorker.cs
- FirstMatchCodeGroup.cs
- BindingGroup.cs
- BrushConverter.cs
- KernelTypeValidation.cs
- Table.cs