Thread: PlaySound

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    162

    PlaySound

    Code was changed to this ...
    Have no idea whats is wrong

    #include <windows.h>
    #include <Mmsystem.h>

    #include "resource.h"

    HINSTANCE hInstance;

    void OnPlay(HWND hwndDlg)
    {
    PlaySound(MAKEINTRESOURCE(IDR_SOUND), hInstance, SND_RESOURCE | SND_ASYNC );
    }


    INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    switch ( uMsg )
    {
    case WM_COMMAND:
    switch ( LOWORD(wParam) )
    {
    case IDCEXIT:
    EndDialog(hwndDlg, LOWORD(wParam));

    case IDOK:
    OnPlay(hwndDlg);
    break;

    }
    break;
    }
    return FALSE;
    }


    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
    LPSTR lpCmdLine, int nShow)
    {
    return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG),
    NULL, (DLGPROC)DialogProc);
    }
    The error note: main.obj : error LNK2019: unresolved external symbol __imp__PlaySoundA@12 referenced in function "void __cdecl OnPlay(struct HWND__ *)" (?OnPlay@@YAXPAUHWND__@@@Z)
    Last edited by Gordon; 04-28-2007 at 05:54 AM. Reason: Change of code

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you should open the programmers guid http://msdn2.microsoft.com/en-us/library/ms712879.aspx
    and look at the Library: Use Winmm.lib. line
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PlaySound doesn't play when called!
    By Queatrix in forum Windows Programming
    Replies: 7
    Last Post: 03-03-2006, 08:02 PM
  2. PlaySound error
    By Shadow12345 in forum Windows Programming
    Replies: 5
    Last Post: 10-02-2002, 07:10 AM
  3. PlaySound function & Console App
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 06-26-2002, 12:25 PM
  4. about playsound()
    By Sekti in forum C++ Programming
    Replies: 0
    Last Post: 04-08-2002, 05:29 PM
  5. PlaySound();
    By tHaPuTeR in forum Windows Programming
    Replies: 2
    Last Post: 03-11-2002, 07:30 AM