UpdateResource

  BOOL UpdateResource(hUpdateFile, lpszType, lpszName, IDLanguage, lpvData, cbData)    
  HANDLE hUpdateFile; /* handle returned by BeginUpdateResource */
  LPTSTR lpszType; /* resource type to update */
  LPTSTR lpszName; /* resource name to update */
  WORD IDLanguage; /* language ID of resource */
  LPVOID lpvData; /* address of resource data */
  DWORD cbData; /* length of resource data in bytes */

The UpdateResource function adds, deletes or replaces a resource in an executable file.

Parameters

hUpdateFile

Specifies an update handle. This handle is returned by the BeginUpdateResource function.

lpszType

Points to a null-terminated string that specifies the resource type to be updated. This parameter may also be an integer value passed to the MAKEINTRESOURCE macro, or one of the predefined resource types shown in the following list:

Value Meaning

RT_ACCELERATOR  
  Accelerator table
RT_BITMAP  
  Bitmap resource
RT_DIALOG  
  Dialog box
RT_FONT  
  Font resource
RT_FONTDIR  
  Font directory resource
RT_MENU  
  Menu resource
RT_RCDATA  
  User-defined resource (raw data)
RT_STRING  
  String-table entry
RT_MESSAGETABLE  
  Message-table entry
RT_CURSOR  
  Hardware-dependent cursor resource
RT_GROUP_CURSOR  
  Hardware-independent cursor resource
RT_ICON  
  Hardware-dependent icon resource
RT_GROUP_ICON  
  Hardware-independent icon resource
RT_VERSION  
  Version resource

lpszName

Points to a null-terminated string that specifies the name of the resource to be updated. This parameter may also be an integer value passed to the MAKEINTRESOURCE macro.

IDLanguage

Specifies the language ID of the resource to be updated.

lpvData

Points to the resource data to be inserted into the executable file. If the resource is one of the predefined types, the data must be valid and properly aligned. Note that this is the raw binary data stored in the executable file, not the data provided by LoadIcon, LoadString, or the other resource-specific load functions. All data that contains strings or text must be in Unicode format; lpvData must not point to ANSI data.

If lpvData is NULL, the specified resource will be deleted from the executable file.

cbData

Specifies the size of the resource data at lpvData.

Return Value

If the function is successful (the resource was added to, deleted from, or replaced in the executable file) the return value is TRUE. Otherwise, the return value is FALSE. Use the GetLastError function to obtain extended error information.

Comments

An application must use the EndUpdateResource function to complete the resource update process.

The UpdateResource function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

BeginUpdateResource, EndUpdateResource, LockResource, SizeOfResource