Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Sys / System / Media / SystemSounds.cs / 1305376 / SystemSounds.cs
using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Runtime.Versioning; 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)] [ResourceExposure(ResourceScope.None)] 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
- StateInitialization.cs
- InvalidCastException.cs
- ColorContext.cs
- SafeFileMappingHandle.cs
- OpCodes.cs
- VirtualDirectoryMapping.cs
- Input.cs
- UserNameSecurityTokenProvider.cs
- SignatureConfirmations.cs
- GiveFeedbackEventArgs.cs
- CachedPathData.cs
- StringUtil.cs
- OptimalBreakSession.cs
- StringFormat.cs
- FilterableAttribute.cs
- SmiEventSink_Default.cs
- SpeechRecognizer.cs
- QilIterator.cs
- HtmlElementEventArgs.cs
- WebPartVerbsEventArgs.cs
- MinMaxParagraphWidth.cs
- Number.cs
- Track.cs
- TreeNodeCollection.cs
- ScrollBar.cs
- NameTable.cs
- QueryOpeningEnumerator.cs
- HtmlDocument.cs
- WebBaseEventKeyComparer.cs
- BitmapSizeOptions.cs
- DynamicQueryableWrapper.cs
- Base64Decoder.cs
- ResourceDescriptionAttribute.cs
- basemetadatamappingvisitor.cs
- cookie.cs
- DebugViewWriter.cs
- AxImporter.cs
- DirectoryNotFoundException.cs
- DependencyPropertyValueSerializer.cs
- WebMessageEncodingElement.cs
- Point4DValueSerializer.cs
- ViewGenResults.cs
- XmlEncodedRawTextWriter.cs
- ShapeTypeface.cs
- WebControl.cs
- HttpHandlerAction.cs
- SecurityException.cs
- DataObjectEventArgs.cs
- DerivedKeyCachingSecurityTokenSerializer.cs
- QueryOutputWriterV1.cs
- GridViewCancelEditEventArgs.cs
- TableProviderWrapper.cs
- DbConnectionStringBuilder.cs
- ArrayTypeMismatchException.cs
- _Semaphore.cs
- ImportCatalogPart.cs
- WindowsScrollBarBits.cs
- Util.cs
- ItemCollection.cs
- DBSqlParserTable.cs
- OwnerDrawPropertyBag.cs
- WorkflowInstanceProxy.cs
- EventDescriptorCollection.cs
- ValidationHelper.cs
- ConfigurationElementProperty.cs
- IProducerConsumerCollection.cs
- XsdBuildProvider.cs
- ExitEventArgs.cs
- Freezable.cs
- QuaternionRotation3D.cs
- DataObjectCopyingEventArgs.cs
- ObsoleteAttribute.cs
- OracleConnectionFactory.cs
- PropertyTab.cs
- MenuItemCollection.cs
- IMembershipProvider.cs
- BitmapInitialize.cs
- Vector3DIndependentAnimationStorage.cs
- WorkItem.cs
- ControlAdapter.cs
- PropertyValueEditor.cs
- Compiler.cs
- SoapObjectReader.cs
- WsdlServiceChannelBuilder.cs
- securitycriticaldata.cs
- MimeImporter.cs
- IsolatedStoragePermission.cs
- XPathSelfQuery.cs
- JournalEntryStack.cs
- OdbcCommandBuilder.cs
- BinaryCommonClasses.cs
- DomainConstraint.cs
- XmlDocumentFragment.cs
- Int16.cs
- StorageTypeMapping.cs
- WebEventTraceProvider.cs
- WSFederationHttpBindingCollectionElement.cs
- LogSwitch.cs
- TextServicesProperty.cs
- Overlapped.cs