Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Using Resource Files
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Nov 3rd, 2003 05:56 AM    Post subject: Using Resource Files Reply with quote

Resource files ( .RES extension ) allow you to embed many types of files inside your EXE , including: flash,avi,bmp,jpg,gif,txt files,exe's,wav.. and many more

**********************************************************
1) Open up VB and from the Add-Ins menu, choose Add-In Manager.
2) Locate and double-click VB 6 Resource Editor, and then click OK.
3) This will add a toolbar button that looks like a Microsoft Registry icon. Click it to open the editor.
4) Now click the Add Custom Resource button in the editor, it's next to the question mark button.
5) Locate and select your flash movie.
6) Do the same with the rest of your movies.
7) Now double click the entry that says 101.
Change the text in the Type box to something descriptive, like FlashMovies.
9) You can also change the ID to something more meaningful, like Home, or Next or whatever.
10) Do the same thing with the rest.
11) Each ID has to be unique under each Type.
12) So if you were to add another Type, you could still have an ID named Home, or whatever.
13) Now click the Save button to save the resource file.
14) You'll now see your resource file under Related Documents in the Project files window.(Where it lists your forms and modules)

**********************************************************

Heres a few examples:

1) WAVS:

Code:
Option Explicit

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
Private Const SND_NODEFAULT = &H2  '  silence not default, if sound not found

Private Sub Form_Load()
  Dim SoundBuffer As String
  SoundBuffer = StrConv(LoadResData("MYSOUND", "WAVE"), vbUnicode)
  sndPlaySound SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY
End Sub


2) EXES:
Code:
Private Sub Form_Load()
  Dim sBuffer As String
    sBuffer = StrConv(LoadResData("setup", "EXE"), vbUnicode)
    Open App.Path & "\setup.exe" For Output As #1
    Print #1, sBuffer
    Close #1
end sub


3) IMAGES:
Code:
Private Sub Form_Load()
Picture1.Picture = LoadResPicture("picture", "yourpic")
End Sub

There we go.. theres some examples
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
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


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic