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
- TypeContext.cs
- X509Certificate2Collection.cs
- TagNameToTypeMapper.cs
- Missing.cs
- DataView.cs
- LateBoundBitmapDecoder.cs
- TdsParserHelperClasses.cs
- EventTrigger.cs
- CreateRefExpr.cs
- WebBaseEventKeyComparer.cs
- SecurityIdentifierConverter.cs
- FormsAuthenticationModule.cs
- TraceInternal.cs
- ClientSponsor.cs
- SQLMoneyStorage.cs
- InputProcessorProfilesLoader.cs
- AuthStoreRoleProvider.cs
- PrimitiveXmlSerializers.cs
- PermissionAttributes.cs
- TableLayoutStyle.cs
- DateTimeFormatInfoScanner.cs
- HebrewCalendar.cs
- SqlConnectionString.cs
- ItemsPresenter.cs
- Thumb.cs
- ControlUtil.cs
- MetaTable.cs
- SortedList.cs
- ScrollPatternIdentifiers.cs
- DataGridViewCellPaintingEventArgs.cs
- SecurityUtils.cs
- XmlDictionaryWriter.cs
- CultureInfo.cs
- UniqueCodeIdentifierScope.cs
- _UriSyntax.cs
- ColumnMapTranslator.cs
- ToolStripContentPanel.cs
- IndexedString.cs
- ConfigUtil.cs
- SponsorHelper.cs
- TextTreeExtractElementUndoUnit.cs
- StoryFragments.cs
- GorillaCodec.cs
- TemplateControlParser.cs
- RenderOptions.cs
- DataGridViewAdvancedBorderStyle.cs
- TempEnvironment.cs
- HyperLinkColumn.cs
- PersonalizationAdministration.cs
- DataSvcMapFileSerializer.cs
- StringAnimationBase.cs
- Profiler.cs
- PolicyVersion.cs
- StringWriter.cs
- MimeXmlImporter.cs
- XmlSchemaInclude.cs
- SqlNotificationRequest.cs
- EntityKeyElement.cs
- StreamReader.cs
- InitializerFacet.cs
- XamlFxTrace.cs
- FullTextLine.cs
- CustomValidator.cs
- PlanCompilerUtil.cs
- OdbcTransaction.cs
- PerformanceCounterLib.cs
- ErrorWrapper.cs
- CacheHelper.cs
- IdleTimeoutMonitor.cs
- SerializerWriterEventHandlers.cs
- Switch.cs
- GeneralTransform3D.cs
- MarshalDirectiveException.cs
- MenuStrip.cs
- TransformValueSerializer.cs
- InputScopeManager.cs
- ExpressionEditorAttribute.cs
- HatchBrush.cs
- XmlDictionaryReader.cs
- ClientConfigPaths.cs
- ComboBoxRenderer.cs
- SafeNativeMethodsCLR.cs
- AsymmetricSignatureDeformatter.cs
- Stylesheet.cs
- Lease.cs
- JoinQueryOperator.cs
- DataContractSerializerServiceBehavior.cs
- GridViewUpdateEventArgs.cs
- TimeManager.cs
- MembershipSection.cs
- PrincipalPermission.cs
- EditorPartChrome.cs
- MD5CryptoServiceProvider.cs
- XmlMembersMapping.cs
- OneOfScalarConst.cs
- DocumentPageHost.cs
- SweepDirectionValidation.cs
- SimplePropertyEntry.cs
- DesignerDataStoredProcedure.cs
- FunctionDetailsReader.cs