Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CommonDialog.cs
- XmlCustomFormatter.cs
- TimeSpanValidatorAttribute.cs
- JoinElimination.cs
- ListChunk.cs
- SaveFileDialog.cs
- NetStream.cs
- QilFactory.cs
- sqlcontext.cs
- ValueCollectionParameterReader.cs
- HttpListenerContext.cs
- TrustLevel.cs
- DataExpression.cs
- CriticalHandle.cs
- DefinitionBase.cs
- DiscoveryDocumentSerializer.cs
- Utility.cs
- DeobfuscatingStream.cs
- TypeNameParser.cs
- GridViewColumnCollection.cs
- ReflectionTypeLoadException.cs
- XmlReflectionMember.cs
- BitmapDecoder.cs
- DataServiceRequestOfT.cs
- Image.cs
- NestedContainer.cs
- SerializerWriterEventHandlers.cs
- SqlTriggerAttribute.cs
- DataGridDetailsPresenterAutomationPeer.cs
- FixedPage.cs
- RemoteWebConfigurationHostServer.cs
- HostedNamedPipeTransportManager.cs
- CallSite.cs
- MatrixValueSerializer.cs
- Encoder.cs
- DmlSqlGenerator.cs
- HttpCacheParams.cs
- ToolTip.cs
- CompositeFontFamily.cs
- EntitySet.cs
- DBBindings.cs
- SecuritySessionFilter.cs
- WebService.cs
- SchemaImporter.cs
- XPathSelfQuery.cs
- IpcChannel.cs
- InstanceDescriptor.cs
- initElementDictionary.cs
- ExecutionTracker.cs
- BorderGapMaskConverter.cs
- DataGridColumnCollection.cs
- ToolBarButton.cs
- SqlConnectionHelper.cs
- BCLDebug.cs
- AbstractExpressions.cs
- MethodExpr.cs
- RepeatBehaviorConverter.cs
- CacheChildrenQuery.cs
- ImmutableCommunicationTimeouts.cs
- ellipse.cs
- ModulesEntry.cs
- MetadataCollection.cs
- TextChangedEventArgs.cs
- NonVisualControlAttribute.cs
- InvalidateEvent.cs
- AnnotationComponentManager.cs
- UniqueEventHelper.cs
- SystemWebSectionGroup.cs
- ThreadStateException.cs
- RequestQueryProcessor.cs
- RootBrowserWindowAutomationPeer.cs
- FixedSOMTable.cs
- SmtpMail.cs
- ConfigPathUtility.cs
- TextSerializer.cs
- XmlBuffer.cs
- DataGridViewRowsAddedEventArgs.cs
- EventPrivateKey.cs
- KnownTypes.cs
- IDispatchConstantAttribute.cs
- TTSEngineProxy.cs
- WindowsFormsSynchronizationContext.cs
- XmlHierarchyData.cs
- ExpressionBinding.cs
- ThrowHelper.cs
- TimelineGroup.cs
- StreamWriter.cs
- AtlasWeb.Designer.cs
- ThreadExceptionEvent.cs
- DetailsView.cs
- ConstraintStruct.cs
- FailedToStartupUIException.cs
- HtmlCommandAdapter.cs
- StrongNameUtility.cs
- SelectionService.cs
- ModuleBuilderData.cs
- GeometryModel3D.cs
- ConfigXmlText.cs
- NamedObject.cs
- SystemDiagnosticsSection.cs