PlaySound

This is a discussion on PlaySound within the Windows Programming forums, part of the Platform Specific Boards category; Code was changed to this ... Have no idea whats is wrong #include <windows.h> #include <Mmsystem.h> #include "resource.h" HINSTANCE hInstance; ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,454
    you should open the programmers guid http://msdn2.microsoft.com/en-us/library/ms712879.aspx
    and look at the Library: Use Winmm.lib. line
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 07: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, 06:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21