updateresource (kernel32)
Last changed: -83.226.86.117

.
Summary

C# Signature:

[DllImport("kernel32.dll", SetLastError=true)]
static extern bool UpdateResource(IntPtr hUpdate, IntPtr lpType, IntPtr lpName, ushort wLanguage, IntPtr lpData, uint cbData);

VB.NET Signature:

<DllImport("kernel32.dll", EntryPoint:="UpdateResource", SetLastError:=True)> _
Friend Shared Function UpdateResource(hUpdate As IntPtr, lpType As IntPtr, lpName As IntPtr, wLanguage As UShort, <MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=5)> lpData As Byte(), cbData As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function

User-Defined Types:

None.

Notes:

See BeginUpdateResource to get a handle for hUpdate, and EndUpdateResource to apply the update changes.

Sending NULL to lpData and 0 to cbData will delete the file indicated by hUpdate.

Most if not all windows resource names are actually numbers, not strings (but some utilities such as Resource Hacker do not show the data type of the resource name). I'm not actually sure if the data type is unsigned 16 bit, but that's the most conservative choice and it does work.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation