첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ PlaySound API 함수를 선언하는 방법을 보여준다.

 

▶ 예제 코드 (C#)

using System;
using System.Runtime.InteropServices;

#region 사운드 재생하기 - PlaySound(soundName, moduleName, flag)

/// <summary>
/// 사운드 재생하기
/// </summary>
/// <param name="soundName">사운드명</param>
/// <param name="moduleName">모듈명</param>
/// <param name="flag">플래그</param>
/// <returns>처리 결과</returns>
[DllImport("winmm", CharSet = CharSet.Auto)]
private extern static int PlaySound(string soundName, IntPtr moduleName, int flag);

#endregion

#region 플래그 - Flag

/// <summary>
/// 플래그
/// </summary>
private enum Flag
{
    /// <summary>
    /// SND_SYNC
    /// </summary>
    /// <remarks>play synchronously (default)</remarks>
    SND_SYNC = 0x0000,

    /// <summary>
    /// SND_ASYNC
    /// </summary>
    /// <remarks>play asynchronously</remarks>
    SND_ASYNC = 0x0001,

    /// <summary>
    /// SND_NODEFAULT
    /// </summary>
    /// <remarks>silence (!default) if sound not found</remarks>
    SND_NODEFAULT = 0x0002,

    /// <summary>
    /// SND_MEMORY
    /// </summary>
    /// <remarks>soundName points to a memory file</remarks>
    SND_MEMORY = 0x0004,

    /// <summary>
    /// loop the sound until next PlaySound
    /// </summary>
    SND_LOOP = 0x0008,

    /// <summary>
    /// SND_NOSTOP
    /// </summary>
    /// <remarks>don't stop any currently playing sound</remarks>
    SND_NOSTOP = 0x0010,

    /// <summary>
    /// SND_NOWAIT
    /// </summary>
    /// <remarks>don't wait if the driver is busy</remarks>
    SND_NOWAIT = 0x00002000,

    /// <summary>
    /// SND_ALIAS
    /// </summary>
    /// <remarks>name is a registry alias</remarks>
    SND_ALIAS = 0x00010000,

    /// <summary>
    /// SND_ALIAS_ID
    /// </summary>
    /// <remarks>alias is a predefined ID</remarks>
    SND_ALIAS_ID = 0x00110000,

    /// <summary>
    /// SND_FILENAME
    /// </summary>
    /// <remarks>name is file name</remarks>
    SND_FILENAME = 0x00020000,

    /// <summary>
    /// SND_RESOURCE
    /// </summary>
    /// <remarks>name is resource name or atom</remarks>
    SND_RESOURCE = 0x00040004
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요