A
animelubitel
я хочу добавить и извлучь ресурс из dll или exe файла, но неполучается вот код:
Private Declare Function BeginUpdateResource Lib "kernel32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Boolean) As Long
Private Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long, lpData As Any, ByVal cbData As Long) As Long выдает ошибку что значение any не используется в диклаке функциях(вроде с visual studio 2008)
djn lheufz
Public Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Integer, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Integer, ByRef lpData As Byte, ByVal cbData As Integer) As Integer
Private Declare Function EndUpdateResource Lib "kernel32" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Long) As Long
код этого человека
Public Function WriteResource(ByVal filename As String, ByVal bytes As Byte()) As Boolean
Try
Dim handle As IntPtr = BeginUpdateResource(filename, False)
Dim file1 As Byte() = bytes
Dim fileptr As IntPtr = ToPtr(file1) выдает ошибку ToPtr
Dim res As Boolean = UpdateResource(handle, "RT_RCDATA", "VIDEO", 0, fileptr, Convert.ToUInt32(file1.Length))
EndUpdateResource(handle, False)
Catch ex As Exception
Return False
End Try
Return True
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim buffer As Byte() = My.Computer.FileSystem.ReadAllBytes("D:\video.avi")
WriteResource("D:\video.avi", Buffer)
мой код
Public Function WriteResource(ByVal filename As String, ByVal buffer As Byte()) As Boolean
'Public Function WriteResource(ByVal filename As String, ByVal buffer As Object()) As Boolean
Try
Dim Explorer As Long = BeginUpdateResource(filename, False)
Dim res As Boolean = UpdateResource(Explorer, "RT_BITMAP пробовал RC_DATA", "6801", 0, Buffer,buffer.Length) ошибку не выдает
EndUpdateResource(Explorer, False)
Catch ex As Exception
Return False
End Try
Return True
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim buffer As Byte() = My.Computer.FileSystem.ReadAllBytes("D:\video.avi")
WriteResource("D:\Новаяпапка\explorer.exe", Buffer)
ниче неизменяет в файле
и может напишете как извлечь
очень нужно, пожалуйста, помогите,очень, жду ответов
Private Declare Function BeginUpdateResource Lib "kernel32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Boolean) As Long
Private Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long, lpData As Any, ByVal cbData As Long) As Long выдает ошибку что значение any не используется в диклаке функциях(вроде с visual studio 2008)
djn lheufz
Public Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Integer, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Integer, ByRef lpData As Byte, ByVal cbData As Integer) As Integer
Private Declare Function EndUpdateResource Lib "kernel32" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Long) As Long
код этого человека
Public Function WriteResource(ByVal filename As String, ByVal bytes As Byte()) As Boolean
Try
Dim handle As IntPtr = BeginUpdateResource(filename, False)
Dim file1 As Byte() = bytes
Dim fileptr As IntPtr = ToPtr(file1) выдает ошибку ToPtr
Dim res As Boolean = UpdateResource(handle, "RT_RCDATA", "VIDEO", 0, fileptr, Convert.ToUInt32(file1.Length))
EndUpdateResource(handle, False)
Catch ex As Exception
Return False
End Try
Return True
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim buffer As Byte() = My.Computer.FileSystem.ReadAllBytes("D:\video.avi")
WriteResource("D:\video.avi", Buffer)
мой код
Public Function WriteResource(ByVal filename As String, ByVal buffer As Byte()) As Boolean
'Public Function WriteResource(ByVal filename As String, ByVal buffer As Object()) As Boolean
Try
Dim Explorer As Long = BeginUpdateResource(filename, False)
Dim res As Boolean = UpdateResource(Explorer, "RT_BITMAP пробовал RC_DATA", "6801", 0, Buffer,buffer.Length) ошибку не выдает
EndUpdateResource(Explorer, False)
Catch ex As Exception
Return False
End Try
Return True
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim buffer As Byte() = My.Computer.FileSystem.ReadAllBytes("D:\video.avi")
WriteResource("D:\Новаяпапка\explorer.exe", Buffer)
ниче неизменяет в файле
и может напишете как извлечь
очень нужно, пожалуйста, помогите,очень, жду ответов