Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
updateresource (kernel32)

C# Signature:

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

VB.NET Signature:

<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function UpdateResource(ByVal hUpdate As IntPtr, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As UInt16, ByVal lpData As IntPtr, ByVal cbData As UInt16) As Boolean
End Function

User-Defined Types:



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!

You can also send a byte[] to lpData with the content of the resource (with byte[] instead of IntPtr as the type for lpData), but I'm not sure how safe this is.

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version