Returns a handle that can be used by the UpdateResource function to add, delete, or replace resources in a binary module.
Syntax
HANDLE BeginUpdateResource(
LPCTSTR pFileName,
BOOL bDeleteExistingResources
);
Parameters
- pFileName
-
[in] Pointer to a null-terminated string that specifies the binary file in which to update resources. An application must be able to obtain write-access to this file; the file referenced by pFileName cannot be currently executing. If pFileName does not specify a full path, the system searches for the file in the current directory.
- bDeleteExistingResources
-
[in] Specifies whether to delete the pFileName parameter's existing resources. If this parameter is TRUE, existing resources are deleted and the updated file includes only resources added with the UpdateResource function. If this parameter is FALSE, the updated file includes existing resources unless they are explicitly deleted or replaced by using UpdateResource.
Return Value
If the function succeeds, the return value is a handle that can be used by the UpdateResource and EndUpdateResource functions. The return value is NULL if the specified file is not a portable executable (PE), the file does not exist, or the file cannot be opened for writing. To get extended error information, call GetLastError.
Remarks
It is recommended that the resource file is not loaded before this function is called. However, if that file is already loaded, it will not cause an error to be returned.
There are some restrictions on resource updates in files that contain Resource Configuration (RC Config) data: LN files and the associated .mui files. Details on which types of resources are allowed to be updated in these files are in the Remarks section for the UpdateResource function.
Windows 95/98/Me: BeginUpdateResourceW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
This function can update resources within modules that contain both code and resources. As noted above, there are restrictions on resource updates in LN files and .mui files, both of which contain RC Config data; details of the restrictions are in the reference for the UpdateResource function.
Example
For an example see, Updating Resources.
Function Information
| Minimum DLL Version | kernel32.dll |
|---|
| Header | Declared in Winbase.h, include Windows.h |
|---|
| Import library | Kernel32.lib |
|---|
| Minimum operating systems |
Windows NT 3.1 |
|---|
| Unicode | Implemented as
ANSI and Unicode versions. |
|---|
See Also