forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


View DSR
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Nov 18, 2004 11:55 pm    Post subject: Reply with quote

Yes please do post it in a separate topic if you want to.

But here's a possible solution: add the resource as a BINARY resource,
and before you run the program, extract the resource using the
BINFILE SAVERES command of VDS 5. Smile

VDS 5 Help File wrote:
BINFILE SAVERES command allows a user defined resource that has been linked in to the executable file to be saved to disk using the specified filename and path.



Note that the <resource type> should be a user defined resource type name such as BINARY, which was used in the #RESOURCE directive that specified the file to be linked. Windows-supported resource types such as ICON and BITMAP are stored using ordinal type names.



If the <resource type> is specified as (for example) "BITMAP" then the resource will not be found, as there is no actual type with this name.



It is possible to access Windows-supported resources using the ordinal number, if you know it. However, most Windows-supported resource types are stored in a special resource format which is not the same as the format used on disk. If a resource such as a bitmap or icon is saved to disk using the BINFILE SAVERES command it will not be readable by a bitmap or icon editor. Therefore, it is important that user-defined types are used when linking resources intended to be used with this command, to ensure that they are linked as raw binary data.

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Fri Nov 19, 2004 3:53 am    Post subject: Reply with quote

OK, thanks guys.
I'll have to check out eh binfile feature Smile

Cheers

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Nov 19, 2004 9:03 am    Post subject: Reply with quote

GeoTrail wrote:
Speaking of resources...
I've added a wave sound file to a program, I can see from the compiler and the filesize that it is included properly, but I can't seem to play it.

tried using
play #filename.wav, wait
but I just heard that ding sound which indicates something is wrong.

Any ideas?


Windows doesn't define a resource type for sound files, and there's no mechanism for playing a sound directly from a resource. The only way to do this is to use BINFILE SAVERES to extract the file to a temporary location, and then play it from there

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Fri Nov 19, 2004 9:18 am    Post subject: Reply with quote

OK, is there somewhere I can get a resource compiler for VDS?
I read in a topic here somwhere that with VDS 3 or 4 registered users got a resource compiler with their registered version.

Or is there a free version out there somehwere I can download?

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1567

PostPosted: Fri Nov 19, 2004 2:54 pm    Post subject: Reply with quote

The resource compiler was for vds 3 and 4, which basically put all external files into a .dsr file and you distributed that with your exe. VDS 5 is much better as it uses standard windows resources built directly into the executable. Take a look at the vds 5 help file or ask people here how to get your files included into the exe, it is rather simple.
Back to top
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Fri Nov 19, 2004 2:57 pm    Post subject: Reply with quote

Yeah, I've already been tipped on the use og binfile, so I'll explore that abit before I bug you again Wink
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Nov 19, 2004 8:55 pm    Post subject: Reply with quote

jules wrote:
GeoTrail wrote:
Speaking of resources...
I've added a wave sound file to a program, I can see from the compiler and the filesize that it is included properly, but I can't seem to play it.

tried using
play #filename.wav, wait
but I just heard that ding sound which indicates something is wrong.

Any ideas?


Windows doesn't define a resource type for sound files, and there's no mechanism for playing a sound directly from a resource. The only way to do this is to use BINFILE SAVERES to extract the file to a temporary location, and then play it from there


Guess again Jules,
Check this out Wink
full working example is in the attached Zip file.

Code:
#---------------------------------------------------------------------------------------#
#                                                                                       #
#                                                                                       #
# Author: Johnny Kinsey                                                                 #
#                                                                                       #
#                                                                                       #
#---------------------------------------------------------------------------------------#
#DEFINE FUNCTION,PlayResource
#DEFINE COMMAND,GADGET
#DEFINE FUNCTION,GADGET
External gadget.dll
Gadget Define,Constant,kernel32,@Gadget(LoadDLL,kernel32.dll)
Gadget Define,Constant,winmm,@Gadget(LoadDLL,winmm.dll)
Gadget Define,Function,GetModuleHandle,kernel32,GetModuleHandle,lpModuleName As String,DWORD
Gadget Define,Function,PlaySoundA,winmm,PlaySound,lpszName As String;hModule As DWORD;dwFlags As DWORD,DWORD


#RESOURCE ADD,WAVE,res/tada.wav,tada
#RESOURCE ADD,WAVE,res/Windows XP Startup.wav,help
Title Play Resource
%%SND_SYNC = $0
%%SND_ASYNC = $1
%%SND_NODEFAULT = $2
%%SND_MEMORY = $4
%%SND_ALIAS = $10000
%%SND_FILENAME = $20000
%%SND_RESOURCE = $40004
%%SND_ALIAS_ID = $110000
%%SND_ALIAS_START = 0
%%SND_LOOP = $8
%%SND_NOSTOP = $10
%%SND_VALID = $1F
%%SND_NOWAIT = $2000
%%SND_VALIDFLAGS = $17201F
%%SND_RESERVED = $FF000000
%%SND_TYPE_MASK = $170007
%%GWL_HINSTANCE = -6
Rem Call our PlayResource function.
Rem Parameter 1 = Path to Exe or DLL with the Wave Resource.
Rem Parameter 2 = The Resource ID
Rem Parameter 3 = The SND flags above.  You can combine them using the @Gadget(Or) function
%%Test = @PlayResource(%0,tada,%%SND_ASYNC)
Info Wait a second.
%%test = @PlayResource(%0,help,%%SND_SYNC)
Info Notice how the info box did not show until the sound was done.
Gadget FreeDLL,kernel32
Gadget FreeDLL,winmm
Exit
:PlayResource
  rem LoadLib kernel32.dll
  rem LoadLib winmm.dll
 
  Rem Get the ID of the wave resource.
  %A = %2
  Rem For some reason VDS would not call this function?
  rem %I = @lib(kernel32,GetModuleHandle,DWORD:,STR:%0)
  REM So I was forced to use Gadget instead Wink
  rem Get the module handle of the file you want to use the wave file from
  %I = @Gadget(GetModuleHandle,%1)
  rem %R = @lib(winmm,PlaySoundA,BOOL:,STR:%A,%I,@Sum(%%SND_RESOURCE,%%SND_SYNC))
  Rem Call the Playsound API function pass it the resource ID, Module Handle, and Set the flags you want to use.
  rem Make sure you use %%SND_RESOURCE.  You can use sync or ASync.  Sync will not return until the wave is done.
  rem
  %R = @Gadget(PlaySound,%A,%I,@Gadget(Or,%%SND_RESOURCE,%3))
Exit %R


Have Fun guys...



PlaySndRes.zip
 Description:
Demostrates using WAVE resources without saving to a file.

Download
 Filename:  PlaySndRes.zip
 Filesize:  546.71 KB
 Downloaded:  1462 Time(s)


_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Nov 19, 2004 9:03 pm    Post subject: Reply with quote

Well the forum the forum said I have met my quota for uploads Question So I had to drop the Exe from the zip above...
_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Fri Nov 19, 2004 9:31 pm    Post subject: Reply with quote

Basically, I think I do it the same way as everyone else:


To load the wave files into the exe:
Code:
  #RESOURCE ADD,BINARY,C:\JFWin\04 - Proposed\Age of Hotkeys\Sounds\btnov.wav,BTNOV
  #RESOURCE ADD,BINARY,C:\JFWin\04 - Proposed\Age of Hotkeys\Sounds\btndn.wav,BTNDN
  #RESOURCE ADD,BINARY,C:\JFWin\04 - Proposed\Age of Hotkeys\Sounds\btnup.wav,BTNUP


Then to dump them out of the exe:
Code:
  IF @not(@file(@path(%0)btnov.wav,Z),0)
    LOADLIB kernel32.dll
    %f = @fill(256,@chr(32))
    %r = @lib(kernel32,GetModuleFileNameA,INT:,NIL:,@addr("%F"),256)
    IF @unequal(@name(%f),vds)
      BINFILE SAVERES,BINARY,BTNOV,@path(%0)btnov.wav
    END
    FREELIB kernel32.dll
  END
  IF @not(@file(@path(%0)btnup.wav,Z),0)
    LOADLIB kernel32.dll
    %f = @fill(256,@chr(32))
    %r = @lib(kernel32,GetModuleFileNameA,INT:,NIL:,@addr("%F"),256)
    IF @unequal(@name(%f),vds)
      BINFILE SAVERES,BINARY,BTNUP,@path(%0)btnup.wav
    END
    FREELIB kernel32.dll
  END
  IF @not(@file(@path(%0)btndn.wav,Z),0)
    LOADLIB kernel32.dll
    %f = @fill(256,@chr(32))
    %r = @lib(kernel32,GetModuleFileNameA,INT:,NIL:,@addr("%F"),256)
    IF @unequal(@name(%f),vds)
      BINFILE SAVERES,BINARY,BTNDN,@path(%0)btndn.wav
    END
    FREELIB kernel32.dll
  END


This works ok in my mind. When the program is closed, I delete
the wav files to cut back on hd space. I also convert the sample
rates of the wav files down as low as possible but not so low that
the sounds begin to lose their quality.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Fri Nov 19, 2004 9:38 pm    Post subject: Reply with quote

Garrett, what does the BTNOV at the end mean?
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Nov 19, 2004 9:41 pm    Post subject: Reply with quote

GeoTrail wrote:
OK, is there somewhere I can get a resource compiler for VDS?
I read in a topic here somwhere that with VDS 3 or 4 registered users got a resource compiler with their registered version.

Or is there a free version out there somehwere I can download?


Actually there is, SSRc.exe is a VDS resource compiler, written in VDS, by
me. It can be downloaded from VdsWorld. I have written a true Win32
command-line compiler for VDS resources (generally used by VDS 3 - 4),
but I haven't posted it as of yet. Although it is finished Confused .

On another note, I'm also in the process of writing a true resource compiler
for compiling resources and linking them an executable Shocked . Along with this
compiler, I'm writing a dll that will extract these resources from the .exe
so that they can then be utilized. Be patient though, I'm having to basically
reinvent the wheel here. This compiler will not be a full blown resource
compiler. It will only compile MENU, MENUEX, STRINGTABLE, BITMAP,
ICON, CURSOR, and ACCELERATORS resources.

And yes, I know that there are plenty of FREE compilers, etc. out there, but
I really don't want to have to distribute third party programs. Hence, I'm
reinventing the wheel Confused

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Fri Nov 19, 2004 9:44 pm    Post subject: Reply with quote

Sounds good bweckel.
Let me know if you need someone to test it Smile

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Nov 19, 2004 9:44 pm    Post subject: Reply with quote

GeoTrail wrote:
Garrett, what does the BTNOV at the end mean?


I believe it is a unique name for each resource. This name is how the
resource is identified by the executable.

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Fri Nov 19, 2004 9:49 pm    Post subject: Reply with quote

bweckel wrote:
GeoTrail wrote:
Garrett, what does the BTNOV at the end mean?


I believe it is a unique name for each resource. This name is how the
resource is identified by the executable.


Sorry, but it escapes my mind why now. Someone else showed us how
to do this quite some time ago and I just can't remember who, what
thread and why. Sad

Also, as I was chatting with Dragonsphere about this, I just realized that
that I'm doubling the memory usage doing this. Not something I want to
do since my goals as I make my programs is to use as little resources as
I possibley can.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Fri Nov 19, 2004 9:53 pm    Post subject: Reply with quote

bweckel wrote:
GeoTrail wrote:
Garrett, what does the BTNOV at the end mean?


I believe it is a unique name for each resource. This name is how the
resource is identified by the executable.
Yes, looks like your right.From the help file:
Quote:
An identifier different from the filename may optionally be specified as an additional parameter. This is not generally advisable. When running a script in the IDE, the linked resource does not exist so it is accessed from its original file. Consequently, the filename must be used in the command that accesses the resource, prefixed by a '#' to show that the resource is to be linked when the executable is made. The ability to specify an identifier is supported for internal use and documented for possible future use by extensions.
It says in not advisable...
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group