Public Function SaveResItemToDisk( _
ByVal iResourceNum As Integer, _
ByVal sResourceType As String, _
ByVal sDestFileName As String _
) As Long
'=============================================
'Saves a resource item to disk
'Returns 0 on success, error number on failure
'=============================================
'Example Call:
' iRetVal = SaveResItemToDisk(101, "CUSTOM", "C:\myImage.gif")
Dim bytResourceData() As Byte
Dim iFileNumOut As Integer
On Error GoTo SaveResItemToDisk_err
'Retrieve the resource contents (data) into a byte array
bytResourceData = LoadResData(iResourceNum, sResourceType)
'Get Free File Handle
iFileNumOut = FreeFile
'Open the output file
Open sDestFileName For Binary Access Write As #iFileNumOut
'Write the resource to the file
Put #iFileNumOut, , bytResourceData
'Close the file
Close #iFileNumOut
'Return 0 for success
SaveResItemToDisk = 0
Exit Function
SaveResItemToDisk_err:
'Return error number
SaveResItemToDisk = Err.Number
End Function
Сейчас этот форум просматривают: SemrushBot и гости: 130