Private Declare Function BeginUpdateResource Lib "kernel32.dll" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Long) As Long
Private Declare Function UpdateResource Lib "kernel32.dll" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As Long, ByRef lpData As Any, ByVal cbData As Long) As Long
Private Declare Function EndUpdateResource Lib "kernel32.dll" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Long) As Long
Private Const RT_VERSION As Long = 16
Private Const LANG_ENGLISH As Long = &H9
Private Const LANG_RUSSIAN As Long = &H19
Private Const LANG_UKRAINIAN As Long = &H22
Private Const LANG_SPANISH As Long = &HA
Public Sub UPDRES(FName As String)
Dim Ret As Long
Dim IPData() As Byte
Dim Hndl As Long
Hndl = BeginUpdateResource(FName, True)
Ret = UpdateResource(Hndl, RT_VERSION, **Имя Ресурса** , LANG_ENGLISH, 0, 0) 'IPData(), Len(IPData)) '...0,0) удалить
EndUpdateResource Hndl, False
End Sub
Option Explicit
Private Const RT_VERSION As Long = 16
Private Const SUBLANG_DEFAULT As Long = &H1
Private Const LANG_NEUTRAL As Integer = &H0
Private Const LANG_ENGLISH As Long = &H9
Private Const LANG_RUSSIAN As Long = &H19
Private Const LANG_UKRAINIAN As Long = &H22
Private Const LANG_SPANISH As Long = &HA
Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long
Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwhandle As Long, ByVal dwlen As Long, lpData As Any) As Long
Private Declare Function BeginUpdateResource Lib "KERNEL32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingReources As Boolean) As Long
Private Declare Function UpdateResource Lib "KERNEL32" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As Long, ByVal lpName As Long, ByVal wLanguage As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function EndUpdateResource Lib "KERNEL32" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Boolean) As Long
Public Sub UpdateFileVersion(ByVal vstrFilePath As String)
Dim llngHandle As Long
Dim llngVersionInfoLength As Long
Dim llngResult As Long
Dim lbytBuffer() As Byte
Dim llngResourceHandle As Long
Dim llngReturnValue As Long
llngVersionInfoLength = GetFileVersionInfoSize(vstrFilePath, llngHandle)
If llngVersionInfoLength <> 0 Then
ReDim lbytBuffer(llngVersionInfoLength)
llngResult = GetFileVersionInfo(vstrFilePath, 0, llngVersionInfoLength, lbytBuffer(0))
If llngResult <> 0 Then
'lbytBuffer(505) = 56
llngResourceHandle = BeginUpdateResource(vstrFilePath, False)
If llngResourceHandle <> 0 Then
'Тут где-то ошибка!
llngReturnValue = UpdateResource(llngResourceHandle, RT_VERSION, 1, 1033, lbytBuffer, UBound(lbytBuffer))
'llngReturnValue = UpdateResource(llngResourceHandle, "Version Info", "1", 1033, VarPtr(lbytBuffer(0)), UBound(lbytBuffer))
'Хотя функция возвращает единицу
If llngReturnValue = 0 Then
MsgBox "Unable to update resource (" & Err.LastDllError & ")", vbExclamation, Me.Caption
End If
llngReturnValue = EndUpdateResource(llngResourceHandle, False)
If llngReturnValue <> 0 Then
MsgBox "Version number updated", vbInformation, Me.Caption
Else
MsgBox "Unable to write updated resource (" & Err.LastDllError & ")", vbExclamation, Me.Caption
End If
Else
MsgBox "Unable to retrieve resource update handle", vbExclamation, Me.Caption
End If
Else
MsgBox "Unable to get file version info (" & Err.LastDllError & ")", vbExclamation, Me.Caption
End If
Else
MsgBox "Unable to get file version info size (" & Err.LastDllError & ")", vbExclamation, Me.Caption
End If
End Sub
Private Function MAKELANGID(ByVal vintPrimaryLanguage As Integer, ByVal _
vintSubLanguage As Integer) As Long
MAKELANGID = (vintSubLanguage * 1024) Or vintPrimaryLanguage
End Function
ApiViewer2004 и MSDN писал(а):Declare Function UpdateResource Lib "kernel32.dll" Alias "UpdateResourceA" ( _
ByVal hUpdate As Long, _
ByVal lpType As String, _
ByVal lpName As String, _
ByVal wLanguage As Long, _
ByRef lpData As Any, _
ByVal cbData As Long) As Long
Этот пример писал(а):Declare Function UpdateResource Lib "kernel32.dll" Alias "UpdateResourceA" ( _
ByVal hUpdate As Long, _
ByVal lpType As Long, _
ByVal lpName As Long, _
ByVal wLanguage As Long, _
ByRef lpData() As Byte, _
ByVal cbData As Long) As Long
Сейчас этот форум просматривают: AhrefsBot и гости: 76