Make your own free website on
Working With Resource File

Lesson 2
Tutorials - Page 1 - Page 2 - Page 3 - Page 4 - Page 5

Accessing GIF and JPG files from your Program
There is no Built-In option to load GIF and JPG files, There is no vbResGIF or vbResJPG.
So to load these files you'll have to use the following Function:

Public Sub LoadDataIntoFile(DataName As Integer, FileName As String)
    Dim myArray() As Byte
myFile As Long
Dir(FileName) = "" Then
        myArray = LoadResData(DataName, "CUSTOM")
        myFile = FreeFile
        Open FileName For Binary Access Write As #myFile
        Put #myFile, , myArray
        Close #myFile
    End If
End Sub

What does this function do?
The function gets two parameters: DataName and FileName.
It simply copy the File that found in the resource file, under the CUSTOM "Folder" With the Id that found in DataName variable.
The new file name will be the String that found in the FileName variable.

For example,  assume I have a resource file, with EXE file that found under the CUSTOM "Folder". The EXE file ID is 101.
Calling to: LoadDataIntoFile 101, "c:\MyDir\myFile.ddd" 
Will copy the EXE file to c:\MyDir\myFile.ddd
It doesn't matter if the file is EXE, GIF, JPG, TXT or WAV.
Because of that, this function can extract any file from resource file, and can be used to extract Sound files, Text files, and other files.

Back  Forward