Search Tools Links Login

Write Resource To File - Fast!

This is a fast way to write a resource to a file. UPDATE: You can find an example to this code here.

Original Author: Jan Philip Matuschek


Filename - Path to the output file, ResID - ID of the resource to write, ResType - Type of the resource to write, Overwrite - Overwrite the output file if it already exists


Public Sub ResToFile(Filename As String, ResID As Variant, ResType As Variant, Optional Overwrite As Boolean = False)
Dim Buffer() As Byte
Dim Filenum As Integer
If Dir(Filename) <> Empty Then 'Check if output file already exists
If Overwrite Then Kill Filename Else Err.Raise 58
End If
Buffer = LoadResData(ResID, ResType) 'Load the resource into a byte array
Filenum = FreeFile
Open Filename For Binary Access Write As Filenum
Put Filenum, , Buffer 'Write the entire array into the file
Close Filenum
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 65 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.