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
- ObjectKeyFrameCollection.cs
- WebBrowserProgressChangedEventHandler.cs
- Stack.cs
- _emptywebproxy.cs
- ThreadSafeList.cs
- Base64Stream.cs
- ProcessHostFactoryHelper.cs
- FlowLayoutSettings.cs
- TransactionProtocolConverter.cs
- PasswordPropertyTextAttribute.cs
- ItemsChangedEventArgs.cs
- ElementProxy.cs
- HostingEnvironmentSection.cs
- SafeTimerHandle.cs
- WebBrowserNavigatedEventHandler.cs
- NonParentingControl.cs
- SharedPersonalizationStateInfo.cs
- KeyFrames.cs
- TraceInternal.cs
- Attachment.cs
- LoginUtil.cs
- RoleGroup.cs
- ConfigurationProperty.cs
- ChannelSinkStacks.cs
- GroupBox.cs
- UITypeEditor.cs
- WmlCalendarAdapter.cs
- SqlMethodCallConverter.cs
- CheckoutException.cs
- EncryptRequest.cs
- TableLayoutRowStyleCollection.cs
- ToolboxItem.cs
- WebPartDisplayModeCancelEventArgs.cs
- DataObject.cs
- StyleBamlRecordReader.cs
- DebugControllerThread.cs
- Enum.cs
- OLEDB_Enum.cs
- DesignerDataSchemaClass.cs
- PassportIdentity.cs
- IdentifierService.cs
- KoreanLunisolarCalendar.cs
- BidOverLoads.cs
- PopOutPanel.cs
- ToolStripDropDownClosedEventArgs.cs
- ReadOnlyAttribute.cs
- SqlTrackingWorkflowInstance.cs
- HttpGetProtocolImporter.cs
- DataServices.cs
- securitymgrsite.cs
- dbdatarecord.cs
- StringFreezingAttribute.cs
- UInt32Converter.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- HyperLinkColumn.cs
- _UriSyntax.cs
- QuaternionConverter.cs
- IfAction.cs
- ChtmlTextBoxAdapter.cs
- COM2PictureConverter.cs
- Adorner.cs
- WebBrowserUriTypeConverter.cs
- BitmapPalettes.cs
- ReliableOutputSessionChannel.cs
- SqlAliaser.cs
- DataGridViewCellStyleBuilderDialog.cs
- ErrorProvider.cs
- HttpConfigurationSystem.cs
- EventProxy.cs
- CustomCredentialPolicy.cs
- CommandField.cs
- BStrWrapper.cs
- RowsCopiedEventArgs.cs
- TemplateGroupCollection.cs
- CatalogPart.cs
- TableLayoutStyleCollection.cs
- PackageFilter.cs
- EventLogStatus.cs
- XmlWrappingWriter.cs
- BrowserCapabilitiesCodeGenerator.cs
- xml.cs
- HwndPanningFeedback.cs
- NativeMethods.cs
- MappedMetaModel.cs
- GatewayIPAddressInformationCollection.cs
- VerificationException.cs
- HttpGetClientProtocol.cs
- MD5CryptoServiceProvider.cs
- XmlSchemaInclude.cs
- OdbcEnvironment.cs
- PageCatalogPart.cs
- IncrementalReadDecoders.cs
- GridViewAutomationPeer.cs
- DesignerLinkAdapter.cs
- XmlIgnoreAttribute.cs
- CodeRegionDirective.cs
- BindableAttribute.cs
- PropertyDescriptorCollection.cs
- ColorContext.cs
- ScriptHandlerFactory.cs