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
BeginUpdateResource (kernel32)

C# Signature:

[DllImport("kernel32.dll", SetLastError=true)]
static extern IntPtr BeginUpdateResource(string pFileName,
   [MarshalAs(UnmanagedType.Bool)]bool bDeleteExistingResources);

VB.NET Signature:

<DllImport("kernel32.dll", SetLastError := False)> _
    Public Shared Function BeginUpdateResource(ByVal pFileName As String, _
    <MarshalAs(UnmanagedType.Bool)> ByVal bDeleteExistingResources As Boolean) As IntPtr
End Function

User-Defined Types:



calls SetLastError. the last error can be retrieved with Marshal.GetLastWin32Error().

Tips & Tricks:

Please add some!

Sample Code:

internal void DelFile(ArrayList fileNames) {
   IntPtr hResource = BeginUpdateResource(mFileName, false);
   if (hResource.ToInt32() == 0) {
     throw new Win32Exception(Marshal.GetLastWin32Error());
   foreach (String fileName in fileNames) {
     if (UpdateResource(hResource, "FILE", fileName,
       MakeLangId(LANG_ENGLISH, SUBLANG_ENGLISH_US), null, 0) == false) {
       throw new Win32Exception(Marshal.GetLastWin32Error());
   if (EndUpdateResource(hResource, false) == false) {
     throw new Win32Exception(Marshal.GetLastWin32Error());

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