:Start of PlaySndResource
![]() | ![]() |
|---|
If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.
# =========================Program Header===============================
# FILENAME: PlaySndResource.dsc
# PROGRAM NAME: Play Sound Resource
# PROGRAM VERSION: 1.00
# INTENDED O/S: Windows 9x, ME, NT, 2000, and XP
# WRITTEN BY: Johnny Kinsey (aka...Dragon Sphere)
# DATE CREATED: December 10, 2005
# EXTERNAL COMPONENTS: gadgetx.dll, Windows XP Startup.wav, tada.wav
# SUGGESTED SCREEN SIZE: 800 x 600 32bit Colors
# =========================Description of Program=======================
#
# Plays WAVE resources that are in EXE's and/or DLL's
#
# DragonSphere Software's Home Page
#
# All Source Files for this demo
#
# ===========================BEGIN SCRIPT==============================
Title Play Sounce Resource
If @Greater(@Name(@Sysinfo(DSVER)),4)
External GadgetX.dll,@SYSINFO(DSVER)
# GadgetX Commands
#DEFINE COMMAND,SET,DEFINE,FREEDLL,CALL
# GadgetX Functions
#DEFINE FUNCTION,GET,LOADDLL,CALL,OR,GETLASTERROR
# User Defined Command
#DEFINE COMMAND,PlayResource
Else
Warn This demo was designed to work with@CR()VDS 5.x from http://www.dialogscript.com
Stop
End
Define Variable,HANDLE,kernel32
Define Variable,HANDLE,winmm
Set kernel32,@LoadDLL(kernel32.dll)
Set winmm,@LoadDLL(winmm.dll)
Define Function,HANDLE,kernel32,GetModuleHandle,GetModuleHandle,String|lpszName
Define Function,DWORD,winmm,PlaySound,PlaySound,String|lpszName,HANDLE|hModule,DWORD|dwFlags
# These are wave resources added to this Exe's resource section
#RESOURCE ADD,WAVE,tada.wav,tada
#RESOURCE ADD,WAVE,Windows XP Startup.wav,help
Define Constant,SND_SYNC,$0
Define Constant,SND_ASYNC,$1
Define Constant,SND_NODEFAULT,$2
Define Constant,SND_MEMORY,$4
Define Constant,SND_ALIAS,$10000
Define Constant,SND_FILENAME,$20000
Define Constant,SND_RESOURCE,$40004
Define Constant,SND_ALIAS_ID,$110000
Define Constant,SND_ALIAS_START,0
Define Constant,SND_LOOP,$8
Define Constant,SND_NOSTOP,$10
Define Constant,SND_VALID,$1F
Define Constant,SND_NOWAIT,$2000
Define Constant,SND_VALIDFLAGS,$17201F
Define Constant,SND_RESERVED,$FF000000
Define Constant,SND_TYPE_MASK,$170007
Define Constant,GWL_HINSTANCE,-6
# Call our PlayResource Command.
# Parameter 1 = Path to Exe or DLL with the Wave Resource.
# Parameter 2 = The Resource ID
# Parameter 3 = The SND flags above. You can combine them using the GadgetX @Or() function
PlayResource %0,tada,@Or(SND_RESOURCE,SND_ASYNC)
Info Wait for the sound to finish.
PlayResource %0,help,@Or(SND_RESOURCE,SND_SYNC)
Info Notice how the info box did not show until the sound was done.
:CLOSE
FreeDLL winmm
FreeDLL kernel32
Exit
:PlayResource
%R =
# Get the ID of the wave resource.
# For some reason VDS would not call this function?
# %I = @lib(kernel32,GetModuleHandle,DWORD:,STR:%0)
# So I was forced to use Gadget instead ;-)
# Get the module handle of the file you want to use the wave file from
%I = @Call(GetModuleHandle,%1)
If %I
# Call the Playsound API function pass it the resource ID, Module Handle, and Set the flags you want to use.
# Make sure you use SND_RESOURCE to read the wave files from the modules resources.
# You can use sync or ASync. Sync will not return until the wave is done.
%R = @Call(PlaySound,%2,%I,%3)
If @Equal(%R,0)
%L = @GetLastError()
If %L
Warn %L
End
End
Else
# If GetModuleHandle fails get the last system error.
%L = @GetLastError()
If %L
Warn %L
End
End
Exit 0
copyright © DragonSphere Software 2000-2006
Terms and Conditions