6 Replies - 1490 Views - Last Post: 17 March 2011 - 09:27 AM

#1 SõftHảcker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-March 11

[Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 05:02 AM

:gun_bandana: PlaySound() doesn't work!

1>------ Erstellen gestartet: Projekt: UnicodeCmdDLL, Konfiguration: Debug Win32 ------
1>Kompilieren...
1>UnicodeCmdDLL.cpp
1>c:\dokumente und einstellungen\andreas\eigene dateien\visual studio 2008\projects\unicode tchar cmd\unicodecmddll\unicodecmddll.cpp(68) : error C2664: 'PlaySoundW': Konvertierung des Parameters 1 von 'std::string' in 'LPCWSTR' nicht möglich
1>        Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden
1>Das Buildprotokoll wurde unter "file://c:\Dokumente und Einstellungen\Andreas\Eigene Dateien\Visual Studio 2008\Projects\Unicode TCHAR CMD\UnicodeCmdDLL\Debug\BuildLog.htm" gespeichert.
1>UnicodeCmdDLL - 1 Fehler, 0 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========



The compiler log is only in german, because I have a german version of Visual C++ 2008 Express.

But I can translate the error:
error C2664 : 'PlaySoundW' cannot convert 'std::string' to 'LPCWSTR'



Here is my piece of code
void PlayWAV(string FILENAME)
	{
		PlaySound(FILENAME, NULL, SND_FILENAME | SND_SYNC);
	}



and it MUST be a string, because this is an DLL, and I want to create a media DLL that can play some audio formats.

I want to add this in my main program

SoftHackerMediaLib::PlayWAV("a_wav_file.wav");
//or
string wavfile = "file.wav";
SoftHackerMediaLib::PlayWAV(wavfile);



is there another method to play wav files from a DLL.
i cannot use Assemblies because it is impossible to add .NET assemblies to DLLs files, i also tried it, and Visual C++ doesn't allow to add .NET assemblies to my DLL Project :devil2:

any help, pls :shit:

Is This A Good Question/Topic? 0
  • +

Replies To: [Question] How to play a WAV file without PlaySound() !?

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: [Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 06:49 AM

Use the SoundPlayer Class?
Was This Post Helpful? 0
  • +
  • -

#3 SõftHảcker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-March 11

Re: [Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 07:04 AM

View Postn8wxs, on 17 March 2011 - 05:49 AM, said:



doesn't work
i can't use assemblies in DLL files
Visual Studio says it is illegal and give me #using-... error

what i'm doing wrong??
Was This Post Helpful? 0
  • +
  • -

#4 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: [Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 07:15 AM

If you are using CLI C++, put the soundplayer in it's own managed DLL.
Was This Post Helpful? 0
  • +
  • -

#5 SõftHảcker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-March 11

Re: [Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 08:37 AM

View Postn8wxs, on 17 March 2011 - 06:15 AM, said:

If you are using CLI C++, put the soundplayer in it's own managed DLL.


how to create managed DLLs, i have a unmanaged :stupid:
Was This Post Helpful? 0
  • +
  • -

#6 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: [Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 09:13 AM

See the various topics: Creating Reusable Code (C++)
Was This Post Helpful? 0
  • +
  • -

#7 SõftHảcker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-March 11

Re: [Question] How to play a WAV file without PlaySound() !?

Posted 17 March 2011 - 09:27 AM

View Postn8wxs, on 17 March 2011 - 08:13 AM, said:

See the various topics: Creating Reusable Code (C++)


very big thanks, i have just created a class library :gunsmilie:
and can add forms to it :bananaman:

thread can be closed now :scooter:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1