Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Sys / System / Media / SystemSounds.cs / 1 / SystemSounds.cs
using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Media { ///[HostProtection(UI = true)] public sealed class SystemSounds { static SystemSound asterisk; static SystemSound beep; static SystemSound exclamation; static SystemSound hand; static SystemSound question; private SystemSounds() { } /// public static SystemSound Asterisk { get { if (asterisk == null) { asterisk = new SystemSound(NativeMethods.MB_ICONASTERISK); } return asterisk; } } /// public static SystemSound Beep { get { if (beep == null) { beep = new SystemSound(0); } return beep; } } /// public static SystemSound Exclamation { get { if (exclamation == null) { exclamation = new SystemSound(NativeMethods.MB_ICONEXCLAMATION); } return exclamation; } } /// public static SystemSound Hand { get { if (hand == null) { hand = new SystemSound(NativeMethods.MB_ICONHAND); } return hand; } } /// public static SystemSound Question { get { if (question == null) { question = new SystemSound(NativeMethods.MB_ICONQUESTION); } return question; } } private class NativeMethods { // Constructor added because of FxCop rules private NativeMethods() {} internal const int MB_ICONHAND = 0x000010, MB_ICONQUESTION = 0x000020, MB_ICONEXCLAMATION = 0x000030, MB_ICONASTERISK = 0x000040; } } /// [HostProtection(UI = true)] public class SystemSound { private int soundType; internal SystemSound(int soundType) { this.soundType = soundType; } /// [SuppressMessage("Microsoft.Security", "CA2106:SecureAsserts")] public void Play() { IntSecurity.UnmanagedCode.Assert(); try { SafeNativeMethods.MessageBeep(soundType); } finally { System.Security.CodeAccessPermission.RevertAssert(); } } private class SafeNativeMethods { // Constructor added because of FxCop rules private SafeNativeMethods() {} [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)] internal static extern bool MessageBeep(int type); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Media { /// [HostProtection(UI = true)] public sealed class SystemSounds { static SystemSound asterisk; static SystemSound beep; static SystemSound exclamation; static SystemSound hand; static SystemSound question; private SystemSounds() { } /// public static SystemSound Asterisk { get { if (asterisk == null) { asterisk = new SystemSound(NativeMethods.MB_ICONASTERISK); } return asterisk; } } /// public static SystemSound Beep { get { if (beep == null) { beep = new SystemSound(0); } return beep; } } /// public static SystemSound Exclamation { get { if (exclamation == null) { exclamation = new SystemSound(NativeMethods.MB_ICONEXCLAMATION); } return exclamation; } } /// public static SystemSound Hand { get { if (hand == null) { hand = new SystemSound(NativeMethods.MB_ICONHAND); } return hand; } } /// public static SystemSound Question { get { if (question == null) { question = new SystemSound(NativeMethods.MB_ICONQUESTION); } return question; } } private class NativeMethods { // Constructor added because of FxCop rules private NativeMethods() {} internal const int MB_ICONHAND = 0x000010, MB_ICONQUESTION = 0x000020, MB_ICONEXCLAMATION = 0x000030, MB_ICONASTERISK = 0x000040; } } /// [HostProtection(UI = true)] public class SystemSound { private int soundType; internal SystemSound(int soundType) { this.soundType = soundType; } /// [SuppressMessage("Microsoft.Security", "CA2106:SecureAsserts")] public void Play() { IntSecurity.UnmanagedCode.Assert(); try { SafeNativeMethods.MessageBeep(soundType); } finally { System.Security.CodeAccessPermission.RevertAssert(); } } private class SafeNativeMethods { // Constructor added because of FxCop rules private SafeNativeMethods() {} [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)] internal static extern bool MessageBeep(int type); } } } // 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
- CompiledIdentityConstraint.cs
- ModelPerspective.cs
- BitmapEffectGroup.cs
- HttpModuleCollection.cs
- State.cs
- TreeNodeBinding.cs
- Attributes.cs
- ClientSettings.cs
- SqlUdtInfo.cs
- ServiceNameCollection.cs
- PerformanceCounterCategory.cs
- Viewport2DVisual3D.cs
- ArithmeticException.cs
- QueryException.cs
- AssociationEndMember.cs
- TextTreeInsertElementUndoUnit.cs
- HandleCollector.cs
- UserControl.cs
- GregorianCalendar.cs
- ExeConfigurationFileMap.cs
- PrintPreviewDialog.cs
- LinearGradientBrush.cs
- SqlClientFactory.cs
- DiffuseMaterial.cs
- FixedSOMFixedBlock.cs
- RC2CryptoServiceProvider.cs
- XPathQilFactory.cs
- _SingleItemRequestCache.cs
- DataGridViewCellConverter.cs
- FontFamilyConverter.cs
- ColumnHeader.cs
- ImageInfo.cs
- Animatable.cs
- VisualCollection.cs
- NetNamedPipeSecurity.cs
- SiteMap.cs
- Debug.cs
- ThumbAutomationPeer.cs
- FtpWebResponse.cs
- StaticSiteMapProvider.cs
- BinaryObjectWriter.cs
- MissingManifestResourceException.cs
- CdpEqualityComparer.cs
- Compiler.cs
- XmlTypeMapping.cs
- WorkflowApplicationEventArgs.cs
- RelationshipSet.cs
- WCFBuildProvider.cs
- NameScopePropertyAttribute.cs
- DictionarySectionHandler.cs
- hwndwrapper.cs
- EditingMode.cs
- FilteredAttributeCollection.cs
- FileLoadException.cs
- RequestCachePolicyConverter.cs
- PartitionResolver.cs
- COM2Properties.cs
- DecoderBestFitFallback.cs
- Header.cs
- IndentedTextWriter.cs
- XmlSchemaSimpleContentExtension.cs
- TraceEventCache.cs
- Content.cs
- CancellationHandlerDesigner.cs
- DataGridViewCellStyleConverter.cs
- X509InitiatorCertificateServiceElement.cs
- PointF.cs
- PageEventArgs.cs
- TransformerTypeCollection.cs
- LazyLoadBehavior.cs
- FolderBrowserDialog.cs
- LogRestartAreaEnumerator.cs
- Viewport3DVisual.cs
- validationstate.cs
- SchemaMerger.cs
- ImageMapEventArgs.cs
- ObjectDataSourceFilteringEventArgs.cs
- TreeNode.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- KeyInterop.cs
- RequestQueryProcessor.cs
- BitmapVisualManager.cs
- CompressEmulationStream.cs
- TableCell.cs
- VerbConverter.cs
- LineProperties.cs
- DesignTimeParseData.cs
- ColorConvertedBitmap.cs
- WebScriptEnablingBehavior.cs
- SQLBytes.cs
- MexTcpBindingElement.cs
- DataViewManager.cs
- DataGridViewBand.cs
- EventEntry.cs
- XmlRawWriter.cs
- ISAPIRuntime.cs
- Exceptions.cs
- TrackingMemoryStreamFactory.cs
- BrowserCapabilitiesFactoryBase.cs
- _ScatterGatherBuffers.cs