Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- ObjectDataSourceChooseMethodsPanel.cs
- RectAnimationClockResource.cs
- DictionaryEditChange.cs
- FormsAuthenticationCredentials.cs
- PKCS1MaskGenerationMethod.cs
- XmlReader.cs
- ExpressionBuilder.cs
- StyleSelector.cs
- GrowingArray.cs
- TdsRecordBufferSetter.cs
- COM2IPerPropertyBrowsingHandler.cs
- BaseParaClient.cs
- SemanticAnalyzer.cs
- StringFunctions.cs
- DataGrid.cs
- PageSettings.cs
- UserPreferenceChangingEventArgs.cs
- X509ChainElement.cs
- TdsRecordBufferSetter.cs
- GZipStream.cs
- unitconverter.cs
- SafeReadContext.cs
- ColumnPropertiesGroup.cs
- DefaultShape.cs
- SimpleHandlerFactory.cs
- MenuItem.cs
- BindingMAnagerBase.cs
- GridLengthConverter.cs
- TagPrefixInfo.cs
- ToolStripControlHost.cs
- Base64WriteStateInfo.cs
- ErrorProvider.cs
- SqlPersonalizationProvider.cs
- GridSplitter.cs
- TreeNodeStyleCollection.cs
- WSFederationHttpSecurityMode.cs
- TextUtf8RawTextWriter.cs
- DataKeyArray.cs
- ShadowGlyph.cs
- FullTextBreakpoint.cs
- oledbconnectionstring.cs
- Int64Storage.cs
- DataGridView.cs
- BinaryOperationBinder.cs
- MsmqHostedTransportConfiguration.cs
- CheckBoxList.cs
- VectorAnimationBase.cs
- XamlGridLengthSerializer.cs
- StringReader.cs
- EntityDataSourceState.cs
- XmlWellformedWriter.cs
- SerializationSectionGroup.cs
- AsyncResult.cs
- OleDbRowUpdatingEvent.cs
- ButtonPopupAdapter.cs
- DBBindings.cs
- Camera.cs
- GroupByExpressionRewriter.cs
- DataControlFieldCell.cs
- TextRunTypographyProperties.cs
- _TLSstream.cs
- DateTimeConverter.cs
- QilChoice.cs
- CompilerCollection.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- ImportCatalogPart.cs
- Directory.cs
- HwndPanningFeedback.cs
- AssemblyUtil.cs
- InvalidComObjectException.cs
- ButtonAutomationPeer.cs
- EncodingInfo.cs
- QilSortKey.cs
- QueryInterceptorAttribute.cs
- Connector.xaml.cs
- SubMenuStyleCollectionEditor.cs
- IdentityModelDictionary.cs
- Constants.cs
- SoapExtensionStream.cs
- WindowsListViewItemStartMenu.cs
- GradientSpreadMethodValidation.cs
- ComAdminInterfaces.cs
- MemoryMappedFile.cs
- PropertyIDSet.cs
- TableItemPattern.cs
- ListParagraph.cs
- SpinLock.cs
- CodeMemberField.cs
- Pair.cs
- FileStream.cs
- TextTreeRootNode.cs
- HopperCache.cs
- AvTraceDetails.cs
- x509utils.cs
- TreeSet.cs
- ElementNotAvailableException.cs
- Decorator.cs
- AppLevelCompilationSectionCache.cs
- _SecureChannel.cs
- DeclarativeConditionsCollection.cs