لإضافة الملف إلى البرنامج يجب تحميل التالي:
Add-InAdd-In Manager...VB6 Resource Editor
أو شيئ مماثل في الفجول بيسيك 5
ثم استخدامه لإضافة ملف الصوت تحت اسم WAVE وبرقم ما خاص لكل ملف صوت مثلا 101 - 102 - 103 ...
ثم يتم حفظ الملف كملف REC والذي سيتم إضافته أوتاميتكيا إلى الملف التنفيذي
ولقراءة (عزف) هذا الملف المضاف فعليك إضافة الكود التالي إلى module:
كود
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Public Sub PlaySoundResource(ResID As Integer)
Dim bSound() As Byte
bSound = LoadResData(ResID, "WAVE")
Dim aSound As String
aSound = Space$(UBound(bSound) + 1)
CopyMemory ByVal aSound, bSound(0), Len(aSound)
sndPlaySound aSound, SND_ASYNC Or SND_MEMORY
End Sub
ثم يتم استدعاؤه ببساطة بالشكل:
كود
PlaySoundResource 101
حيث 101 هو رقم الصوت الذي تريد عزفه والذي تمت إضافته مسبقا.