Friends who have used C know that resources are very important in Windows programming, reasonably use resources
It can make the program more flexible. In fact, in Delphi, you can also make resources, but Delphi this
Many people have a lot of visual programming, there is no explanation for the production of resources, nor is it like Borland.
The resource production tools in C provides resource workshop, which has no relationship, below I will pass
After making the WAV files, compiling the EXE file to introduce how to use Delphi itself.
Tools provided by tools.
16-bit Delphi 1.0 and 32-bit Delphi2.0, 3.0 provide resources
Compilation tool, where Delphi 1.0 resource compiler is called Brcc.exe, Delphi 2.0 resource compiler
Brcc32.exe is used to compile 32-bit resources, and all resource compilers only provide command line versions.
No Windows version is available. Making a resource is usually through the following steps:
1) Write .rc file
..RC file is the source file of the resource, the compiler also compiles this file, generates .res' resource file
First create a plain text file in our project subdirectory, named Sound.rc, file
There is a line, the content is:
Sound1 WAV Sound.wav
Sound.wav is a normal sound file under Windows
2) Compile it
After playing the BRCC Sound.rc hard disk in DOS, after it is completed, it is compiled.
3) Production procedure
This is also the most complex, flexible step, starting Windows, then start Delphi, and projects
The files are saved in the subdirectory in our project. Looking for such a line in Unit1.Pas
{$ R * .dfm}
State our resource files behind
{$ R snound.res}
Then, in Form1, two global variables are declared
PTRSOUND: PCHAR;
HRES: THANDLE; {handle to the loaded resource
IF 0 indeicates nothing playing}
Write the following code in the create event of Form1
Procedure TFORM1.FormCreate (Sender: TOBJECT);
Var HRESINFO: THANDLE;
Begin
HRESINFO: = FindResource (Hinstance, 'Sound1', 'Wave');
HRES: = loading (Hinstance, HRESINFO);
IF hres> 32 THEN {ITS a good load}
Begin {Lock the resource}
PTRSOUND: = LOCKRESOURCE (HRES);
END;
END;
Then put a button button1 in Form1, write the following code:
Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
Begin
SNDPLAYSOUND (PTRSOUND, SND_ASYNC OR SND_MEMORY);
END;
At this time, you can run, of course, this is just an example, just provide call resources.
One way, distance from the actual application. May this TIP will give you a throwing tile
Jade role.