Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / Input / Win32KeyboardDevice.cs / 1 / Win32KeyboardDevice.cs
using System.Collections; using System.Windows; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using System.Windows.Media; using MS.Win32; // VK translation. using System; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The Win32KeyboardDevice class implements the platform specific /// KeyboardDevice features for the Win32 platform /// internal sealed class Win32KeyboardDevice : KeyboardDevice { ////// /// /// /// ////// Critical: This code creates critical data(_tsfManager,_textcompositionManager) and stores critical data (inputManager) /// TreatAsSafe: Although it creates critical data there are demand on the critical data and the constructor is safe /// [SecurityCritical,SecurityTreatAsSafe] internal Win32KeyboardDevice(InputManager inputManager) : base(inputManager) { } ////// Gets the current state of the specified key from the device from the underlying system /// /// /// Key to get the state of /// ////// The state of the specified key /// ////// Critical: Makes calls to UnsafeNativeMethods (GetKeyState) /// TreatAsSafe: Only returns the current state of a specified key /// [SecurityCritical, SecurityTreatAsSafe] protected override KeyStates GetKeyStatesFromSystem(Key key) { KeyStates keyStates = KeyStates.None; // Security Mitigation: do not give out input state if the device is not active. if(IsActive) { int virtualKeyCode = KeyInterop.VirtualKeyFromKey(key); int nativeKeyState; nativeKeyState = UnsafeNativeMethods.GetKeyState(virtualKeyCode); if( (nativeKeyState & 0x00008000) == 0x00008000 ) keyStates |= KeyStates.Down; if( (nativeKeyState & 0x00000001) == 0x00000001 ) keyStates |= KeyStates.Toggled; } return keyStates; } } } // 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
- PointCollectionConverter.cs
- EtwTrace.cs
- CurrentChangingEventArgs.cs
- DataViewManager.cs
- CompensatableSequenceActivity.cs
- EmptyStringExpandableObjectConverter.cs
- ThaiBuddhistCalendar.cs
- KeyTimeConverter.cs
- Frame.cs
- XmlSchemaNotation.cs
- ImageListUtils.cs
- CurrentChangedEventManager.cs
- HitTestParameters3D.cs
- NonSerializedAttribute.cs
- CursorConverter.cs
- ExpressionPrefixAttribute.cs
- JpegBitmapEncoder.cs
- TextViewElement.cs
- StringAnimationBase.cs
- PhysicalOps.cs
- XmlSchemaSimpleTypeRestriction.cs
- SqlXmlStorage.cs
- _SSPIWrapper.cs
- InstancePersistenceException.cs
- MultiDataTrigger.cs
- TaskForm.cs
- KeyToListMap.cs
- DeviceContext.cs
- Point3DAnimationUsingKeyFrames.cs
- State.cs
- StructuralObject.cs
- TemplateComponentConnector.cs
- OdbcEnvironmentHandle.cs
- TogglePatternIdentifiers.cs
- PageCatalogPart.cs
- LinqDataSourceEditData.cs
- LoadRetryAsyncResult.cs
- DataGridViewTextBoxColumn.cs
- UserControlParser.cs
- Button.cs
- BaseCodeDomTreeGenerator.cs
- DataServiceConfiguration.cs
- PassportAuthenticationModule.cs
- XhtmlBasicFormAdapter.cs
- TextPointer.cs
- columnmapkeybuilder.cs
- AsyncOperation.cs
- FilteredAttributeCollection.cs
- StringReader.cs
- ValidationHelpers.cs
- Debug.cs
- ComponentEvent.cs
- ProbeMatchesMessageCD1.cs
- SqlRetyper.cs
- ParallelTimeline.cs
- ConfigXmlElement.cs
- BitmapCodecInfo.cs
- XPathScanner.cs
- RowToParametersTransformer.cs
- TakeOrSkipQueryOperator.cs
- TraceContext.cs
- EdmItemCollection.cs
- TextRangeBase.cs
- XmlQueryTypeFactory.cs
- LayoutEditorPart.cs
- X509Certificate2Collection.cs
- OverflowException.cs
- TableLayoutStyleCollection.cs
- SpotLight.cs
- ImpersonationContext.cs
- BaseParser.cs
- SynchronizationLockException.cs
- ToolTipAutomationPeer.cs
- MasterPageCodeDomTreeGenerator.cs
- DragDrop.cs
- XamlGridLengthSerializer.cs
- FormCollection.cs
- CalendarTable.cs
- GroupBox.cs
- EventLogEntry.cs
- ExchangeUtilities.cs
- GetMemberBinder.cs
- SizeAnimation.cs
- LinkLabelLinkClickedEvent.cs
- MenuStrip.cs
- FormsAuthenticationUser.cs
- Sql8ExpressionRewriter.cs
- ListViewDeleteEventArgs.cs
- OperationInfo.cs
- EntityRecordInfo.cs
- OutputScopeManager.cs
- UserControl.cs
- ConfigurationSectionGroupCollection.cs
- DisplayMemberTemplateSelector.cs
- InheritablePropertyChangeInfo.cs
- SevenBitStream.cs
- BufferBuilder.cs
- CultureInfoConverter.cs
- BamlTreeNode.cs
- BamlLocalizabilityResolver.cs