was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

40 Visitors Online


 
...eine Wav Datei in eine Exe Datei einbinden?
Autor: Thomas Stutz
[ Tip ausdrucken ]  

Tip Bewertung (35):  
     


{* Scroll down for English text. *}


{Schritt 1:

Erstelle eine Script Datei (*.RC) mit einem
Text Editor (z.B Notepad) und füge schreibe etwa folgendes:}

1 WAVE "MyWav.wav"

{'1' gibt den Index der Ressource an.
'WAVE' gibt an, dass es sich um eine Wave Datei handelt.
Und schliesslich gibt der dritte Eintrag den Namen der
Wave Datei an.

Schritt 2:

Speichere nun die Datei als MyWav.RC

Schritt 3:

Mit Borland's Resource Compiler, BRCC32.EXE,
wird die Datei nun in eine .RES Datei compiliert.
Im MS-DOS Prompt, im Verzeichnis wo sich MyWav.RC befindet,
nun folgendes eingeben:}

BRCC32 MyWav.RC

{Dies erzeugt eine Ressourcen-Datei MyWav.Res

Schritt 4:

Nun muss noch eine Compiler Directive dem Sourcecode hinzugefügt werden.
Der Eintrag sollte unmittelbar nach der Form Directive folgen, so wie hier:}

{$R *.DFM}
{$R MyWAV.RES}

{Schritt 5:

So kann dann die Wav-Datei abgespielt werden  }

procedure TForm1.Button1Click(Sender: TObject);
begin
  
PlaySound(PChar(1), hInstance, SND_ASYNC or SND_MEMORY or SND_RESOURCE);
end;

{
  Es können natürlich auch mehrere .Wav Dateien in eine Exe-Datei
  eingebunden werden.
  Einfach eine andere Index Nummer nehmen und anstatt
  PChar(1) PChar(Index) schreiben.

  Tipp: Noch MMSystem der Uses Klausel hinzufügen!
}


{
STEP 1:

Create a resource script file (*.RC) with a simple text editor like
Notepad and add the following line:}

1 WAVE "MyWav.wav"

{The '1' is simply the index of the resource.
The 'WAVE' specifies that we are dealing with a WAVE FILE user-defined resource.
The third and final entry is the name of the Wav file.

STEP 2:

Save the file as MyWav.RC

STEP 3:

User Borland's Resource Compiler, BRCC32.EXE, to compile it into a .RES file.
At the MS-DOS command line, type:}

BRCC32 MyWav.RC

{This will create a resource file called MyWav.RES.

STEP 4:

Add a compiler directive to the source code of your program.  It should immediately
follow the form directive, as shown here:}

{$R *.DFM}
{$R MyWAV.RES}

{STEP 5:

Add the following code to your project to play the sound:
}

procedure TForm1.Button1Click(Sender: TObject);
begin
  
PlaySound(PChar(1), hInstance, SND_ASYNC or SND_MEMORY or SND_RESOURCE);
end;

{
 You can add as many .Wav files as you want,
 just by adding another index number to your list,
 and call it using the PChar(index) in the PlaySound line.

 Hint:  MMSystem must be included in the uses clause!
}


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners