Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PlaySound(...). Can't import winmm.lib?!

Status
Not open for further replies.

gorgor

Programmer
Aug 15, 2002
164
US
I'm trying to play a simple wav file using SDK's PlaySound(...) function. Maybe I'm missing something simple here, but I can't import the winmm.lib file for some reason. Here's what I put at the beginning of the cpp file that I want to use PlaySound() in"

#include <mmsystem.h>
#import &quot;C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\lib\winmm.lib&quot;

I'm getting the error &quot;cannot open type library file&quot;. I know for a fact that it is in that directory. Any ideas? Thanks in advance!
 
Your use of #import is incorrect
A .dll is not normally a type library - it might be, but winmm.dll isn't.

Normally, I would add &quot;winmm.lib&quot; to the project settings.
One of the settings is a dialog which allows you to specify the libraries to be searched. There is a long list of standard libraries, and an additional field to specify your own additions to that list. Add winmm.lib to that list.

--
 
I'm using MSVC .NET and I can't figure out how to add the library to the project. Does anyone know a resource that will guide me through the process? I'd tried .NET help and couldn't what I was looking for.

How frustrating.
 
There is a short sample of playing sound, I've written it in ATL:
#import &quot;G:\WINNT\System32\msdxm.ocx&quot;
#include &quot;Debug\msdxm.tlh&quot;
#include<windows.h>
#include<ole2.h>
#include<string>
#include<atlbase.h>
#include<comip.h>
#include<comdef.h>
#include<comutil.h>
using namespace std;

int main()//ATL
{
CoInitialize(0);
{
CComPtr<IUnknown> x;
_bstr_t mp = L&quot;MediaPlayer.MediaPlayer.1&quot;;
HRESULT hr = x.CoCreateInstance(mp, 0, CLSCTX_LOCAL_SERVER);
MediaPlayer::IMediaPlayer2* pdisp;
hr = x->QueryInterface(&pdisp);
_bstr_t fname = L&quot;d:\\music\\Zinciuc - Paganini caprice N24.mp3&quot;;
_bstr_t xx;
hr = pdisp->Open(fname.GetBSTR());
hr = pdisp->Play();
}
CoUninitialize();
return 0;
}

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
> I'm using MSVC .NET and I can't figure out how to add the library to the project.
Project->Properties...

In the configuration drop-down, select &quot;All Configurations&quot;

Select the Linker &quot;folder&quot; and select &quot;Input&quot;

Click on &quot;Additional Dependencies&quot;, then click on the &quot;...&quot; button which appears to the right.

In the edit box, type in the name(s) of the additional libraries.



--
 
at the top of the file you can write

#pragma comment(lib, &quot;winmm.lib&quot;)

that will link your application to that library

Skute

&quot;There are 10 types of people in this World, those that understand binary, and those that don't!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top