Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / MS / Internal / Utilities.cs / 1305600 / Utilities.cs
/**************************************************************************\ Copyright Microsoft Corporation. All Rights Reserved. \**************************************************************************/ namespace MS.Internal { using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security; using MS.Win32; ////// General utility class for macro-type functions. /// internal static class Utilities { private static readonly Version _osVersion = Environment.OSVersion.Version; internal static bool IsOSVistaOrNewer { get { return _osVersion >= new Version(6, 0); } } internal static bool IsOSWindows7OrNewer { get { return _osVersion >= new Version(6, 1); } } internal static bool IsCompositionEnabled { ////// Critical -- calls into an unsafe native method. /// TreatAsSafe -- the call to DwmIsCompositionEnabled simply returns a boolean /// through an out parameter, it is safe information to expose /// [SecurityCritical, SecurityTreatAsSafe] get { if (!IsOSVistaOrNewer) { return false; } Int32 isDesktopCompositionEnabled = 0; UnsafeNativeMethods.HRESULT.Check(UnsafeNativeMethods.DwmIsCompositionEnabled(out isDesktopCompositionEnabled)); return isDesktopCompositionEnabled != 0; } } internal static void SafeDispose(ref T disposable) where T : IDisposable { // Dispose can safely be called on an object multiple times. IDisposable t = disposable; disposable = default(T); if (null != t) { t.Dispose(); } } /// /// Critical - Suppresses unmanaged code security. Calls Marshal.ReleaseComObject which has a LinkDemand. /// [SuppressUnmanagedCodeSecurity, SecurityCritical] internal static void SafeRelease(ref T comObject) where T : class { T t = comObject; comObject = default(T); if (null != t) { Debug.Assert(Marshal.IsComObject(t)); Marshal.ReleaseComObject(t); } } } } // 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
- QilReplaceVisitor.cs
- IndexingContentUnit.cs
- CustomValidator.cs
- SafeEventLogWriteHandle.cs
- TcpActivation.cs
- QilGenerator.cs
- TableDetailsCollection.cs
- AtlasWeb.Designer.cs
- PointAnimationUsingPath.cs
- KnownTypeDataContractResolver.cs
- X509CertificateCollection.cs
- SafeMemoryMappedViewHandle.cs
- DocumentXPathNavigator.cs
- GridViewCommandEventArgs.cs
- Page.cs
- HtmlHistory.cs
- FormViewPagerRow.cs
- CounterSampleCalculator.cs
- IriParsingElement.cs
- ComMethodElementCollection.cs
- control.ime.cs
- WebPartUtil.cs
- SendSecurityHeaderElementContainer.cs
- ProfileManager.cs
- XmlObjectSerializerReadContext.cs
- HttpProcessUtility.cs
- SortQuery.cs
- DataSourceProvider.cs
- ConnectionProviderAttribute.cs
- TopClause.cs
- IISMapPath.cs
- StyleSelector.cs
- ToolStrip.cs
- WebControlsSection.cs
- StylusEditingBehavior.cs
- DatePickerAutomationPeer.cs
- XamlToRtfParser.cs
- MemberHolder.cs
- Pool.cs
- IChannel.cs
- TabControlDesigner.cs
- BitSet.cs
- ProtocolsConfiguration.cs
- CodeObject.cs
- WindowsSlider.cs
- DictionaryItemsCollection.cs
- SQLDecimalStorage.cs
- SiteMapNode.cs
- WorkflowServiceHostFactory.cs
- diagnosticsswitches.cs
- CodeEventReferenceExpression.cs
- SrgsText.cs
- XmlSchemaSet.cs
- StylusSystemGestureEventArgs.cs
- WorkflowDesigner.cs
- ConfigurationException.cs
- Error.cs
- AnnotationComponentChooser.cs
- ButtonFieldBase.cs
- EventMappingSettingsCollection.cs
- assertwrapper.cs
- RotateTransform3D.cs
- XPathPatternParser.cs
- NetworkInformationException.cs
- SmtpLoginAuthenticationModule.cs
- EmbeddedMailObject.cs
- XhtmlTextWriter.cs
- EditorZone.cs
- DetailsViewModeEventArgs.cs
- SystemWebCachingSectionGroup.cs
- PolicyDesigner.cs
- AssociationSet.cs
- ResourceAttributes.cs
- ColorAnimationBase.cs
- CodeDomDecompiler.cs
- InternalControlCollection.cs
- ToolStripSettings.cs
- DbDataRecord.cs
- TaskFileService.cs
- LogLogRecordEnumerator.cs
- HttpListenerTimeoutManager.cs
- MimeTextImporter.cs
- QilGenerator.cs
- COM2PropertyPageUITypeConverter.cs
- DocumentGridContextMenu.cs
- SafeEventLogWriteHandle.cs
- StringExpressionSet.cs
- dbdatarecord.cs
- EventDescriptor.cs
- ErrorStyle.cs
- SoapExtensionReflector.cs
- TextElement.cs
- Context.cs
- NavigationProperty.cs
- Int32Collection.cs
- SettingsProperty.cs
- DetailsViewUpdatedEventArgs.cs
- MessageFilterException.cs
- PolyQuadraticBezierSegment.cs
- HandleRef.cs