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">https://www.vbcoders.com/xq/ASP/txtCodeId.23155/lngWId.1/qx/vb/scripts/ShowCode.htm">here.
Inputs
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
Rate Write Resource To File Fast
(5(5 Vote))
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
Write Resource To File Fast Comments
No comments yet — be the first to post one!
Post a Comment