UpdateResource Failure
- From: "Papp György" <pappgyorgy@xxxxxxxxxxx>
- Date: Wed, 6 Sep 2006 15:28:19 +0200
Hi
I would like to modify icon resoures in a exe file.
I load the icon file to a byte array and then i pass it to the
updateresource method.
After that, I look into the exe file with the resource hacker, and the icon
is invalid, however it contains the same byte array as I loaded from an
icon.
What did I do wrong?
The source is the following :
Private Sub UpdateIcon(ByVal FileName As String, ByVal Icon_Group As
Boolean, ByVal LCID As Integer, id As Long, ByVal IconFileName As String)
Const NoDelete As Long = 0
Dim ResHandle As Long: ResHandle = Win32.BeginUpdateResource(FileName,
ByVal NoDelete)
If ResHandle = 0 Then
Throw InvalidOperation, Nothing, "Can't access the resource section!"
Else
Dim RT_Type As Long: RT_Type = IIf(Icon_Group, RT_GROUP_ICON,
Win32.RT_ICON) '--- set the resource type
Dim IconBuffer() As Byte: IconBuffer = FileToBuffer(IconFileName)
'--- Load the entire file to a buffer by the get statement
Call UpdateResourceNT(ResHandle, RT_Type, id, LCID, IconBuffer(0), ByVal
CLng(UBound(IconBuffer) - LBound(IconBuffer) + 1))
If Win32.EndUpdateResource(ResHandle, 0) = 0 Then
Debug.Print "Win32.EndUpdateResource Failed"
Throw InvalidConstraint, Nothing, "UpdateResource Failed"
End If
End If
End Sub
.
- Prev by Date: Re: Deliberately make an application "Not Responding"
- Next by Date: How To Read window details before it is created?
- Previous by thread: Re: Create system watch on label
- Next by thread: How To Read window details before it is created?
- Index(es):
Relevant Pages
|