Code:
/ DotNET / DotNET / 8.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
- VectorAnimationBase.cs
- SessionState.cs
- SmiMetaDataProperty.cs
- Camera.cs
- DocComment.cs
- NameValueSectionHandler.cs
- SetterBaseCollection.cs
- LightweightCodeGenerator.cs
- TableMethodGenerator.cs
- DataTemplateKey.cs
- ToolboxCategoryItems.cs
- PasswordDeriveBytes.cs
- InvalidProgramException.cs
- UrlMappingsSection.cs
- CultureTableRecord.cs
- ElementHostAutomationPeer.cs
- SequenceDesigner.cs
- FixedPageProcessor.cs
- BindingMemberInfo.cs
- ObjectMemberMapping.cs
- EntityFunctions.cs
- XmlAttributeCollection.cs
- DatatypeImplementation.cs
- wgx_sdk_version.cs
- XmlChildNodes.cs
- PageHandlerFactory.cs
- TextFindEngine.cs
- SqlComparer.cs
- TdsValueSetter.cs
- WebHttpBindingCollectionElement.cs
- WorkflowTransactionOptions.cs
- FixedTextSelectionProcessor.cs
- FormViewDeletedEventArgs.cs
- DataPointer.cs
- SqlCommandBuilder.cs
- UnsignedPublishLicense.cs
- PipeStream.cs
- ImageConverter.cs
- RsaKeyIdentifierClause.cs
- unsafeIndexingFilterStream.cs
- XMLSyntaxException.cs
- SqlColumnizer.cs
- AccessViolationException.cs
- clipboard.cs
- WebBrowserPermission.cs
- TextRunCacheImp.cs
- TileBrush.cs
- ComPlusDiagnosticTraceSchemas.cs
- Point3DCollection.cs
- CommandHelpers.cs
- RowUpdatedEventArgs.cs
- ProcessHostConfigUtils.cs
- XmlComplianceUtil.cs
- JapaneseLunisolarCalendar.cs
- DataGridViewRowPrePaintEventArgs.cs
- SapiRecoContext.cs
- BufferedStream2.cs
- RequestQueue.cs
- OSFeature.cs
- AstTree.cs
- XmlDataSourceView.cs
- HttpCachePolicy.cs
- HostedElements.cs
- FactorySettingsElement.cs
- mansign.cs
- TextTreeTextBlock.cs
- CallbackHandler.cs
- LayoutDump.cs
- MenuItem.cs
- SignatureResourcePool.cs
- CommandConverter.cs
- TypeSource.cs
- RotateTransform.cs
- Base64Encoder.cs
- ScopelessEnumAttribute.cs
- HandleScope.cs
- LabelEditEvent.cs
- SettingsBindableAttribute.cs
- XPathPatternBuilder.cs
- DPAPIProtectedConfigurationProvider.cs
- RowUpdatedEventArgs.cs
- RenderDataDrawingContext.cs
- XmlEventCache.cs
- ShaderEffect.cs
- FormViewRow.cs
- UserControlAutomationPeer.cs
- DataRowExtensions.cs
- ListView.cs
- FigureHelper.cs
- ClientSettings.cs
- AspProxy.cs
- JsonUriDataContract.cs
- ExpressionWriter.cs
- HttpCacheVary.cs
- Renderer.cs
- StateRuntime.cs
- XmlnsPrefixAttribute.cs
- BitConverter.cs
- MessageSecurityException.cs
- TreeNodeCollectionEditorDialog.cs