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
- AttachInfo.cs
- Setter.cs
- parserscommon.cs
- columnmapkeybuilder.cs
- WebHeaderCollection.cs
- ScriptReferenceBase.cs
- ServiceHttpModule.cs
- KeyedHashAlgorithm.cs
- HttpConfigurationContext.cs
- PrinterUnitConvert.cs
- MultiSelectRootGridEntry.cs
- ComponentChangingEvent.cs
- TextContainerChangedEventArgs.cs
- AutomationPropertyInfo.cs
- StrokeSerializer.cs
- Odbc32.cs
- NotifyCollectionChangedEventArgs.cs
- ProxyDataContractResolver.cs
- ProfileEventArgs.cs
- Crypto.cs
- XmlnsCache.cs
- PropertyGeneratedEventArgs.cs
- PropertyMappingExceptionEventArgs.cs
- AuthenticatedStream.cs
- sqlser.cs
- SimpleRecyclingCache.cs
- ShutDownListener.cs
- DynamicActivityTypeDescriptor.cs
- StrokeIntersection.cs
- DesignerDataSourceView.cs
- TemplatePropertyEntry.cs
- DirtyTextRange.cs
- WebPartCloseVerb.cs
- MethodImplAttribute.cs
- CompiledRegexRunner.cs
- WebPartPersonalization.cs
- LogFlushAsyncResult.cs
- Event.cs
- SrgsGrammarCompiler.cs
- XmlSchemaComplexContentRestriction.cs
- LocalizabilityAttribute.cs
- ScrollChrome.cs
- CallContext.cs
- HtmlTernaryTree.cs
- DrawingGroup.cs
- MailHeaderInfo.cs
- MenuItem.cs
- CalendarDay.cs
- DictionaryBase.cs
- SafeProcessHandle.cs
- IdleTimeoutMonitor.cs
- ThreadStartException.cs
- VisualCollection.cs
- CompressEmulationStream.cs
- DateTimeFormat.cs
- ValidatorCompatibilityHelper.cs
- GridViewEditEventArgs.cs
- BinaryObjectInfo.cs
- ListDictionaryInternal.cs
- TextTreeInsertUndoUnit.cs
- RubberbandSelector.cs
- UseManagedPresentationElement.cs
- Interfaces.cs
- TraceHandlerErrorFormatter.cs
- MailAddressParser.cs
- SelectionUIHandler.cs
- MembershipSection.cs
- LocationUpdates.cs
- precedingsibling.cs
- ExtensionCollection.cs
- CLRBindingWorker.cs
- EditorPartChrome.cs
- InputProviderSite.cs
- AutomationElement.cs
- _SingleItemRequestCache.cs
- DataGridBoolColumn.cs
- RectangleConverter.cs
- SystemResourceKey.cs
- XmlValidatingReaderImpl.cs
- PropertyStore.cs
- WindowsPen.cs
- BufferModesCollection.cs
- PageAsyncTask.cs
- EmptyEnumerator.cs
- DataErrorValidationRule.cs
- newinstructionaction.cs
- RewritingSimplifier.cs
- SecureEnvironment.cs
- RoutedEventHandlerInfo.cs
- FlowLayoutPanel.cs
- CellConstantDomain.cs
- GeometryHitTestParameters.cs
- PointCollection.cs
- CodeObjectCreateExpression.cs
- WebPartEditorApplyVerb.cs
- ITreeGenerator.cs
- RoleManagerSection.cs
- TableFieldsEditor.cs
- Properties.cs
- SerializationInfo.cs