Makes a new image file or opens an existing image file.

HANDLE
WINAPI
WIMCreateFile(
	PWSTR   pszWimPath,
	DWORD   dwDesiredAccess,
	DWORD   dwCreationDisposition,
	DWORD   dwFlagsAndAttributes,
	DWORD   dwCompressionType,
	PDWORD  pdwCreationResult
	);

Parameters

pszWimPath

[in] A pointer to a null-terminated string that specifies the name of the file to create or to open.

dwDesiredAccess

[in] Specifies the type of access to the object. An application can obtain read access, write access, read/write access, or device query access. For this parameter you can use any combination of the following values:

Value Description

0

Specifies query access to the file. An application can query image information without accessing the images.

WIM_GENERIC_READ

Specifies read-only access to the image file. Enables images to be applied from the file. Combine with WIM_GENERIC_WRITE for read/write (append) access.

WIM_GENERIC_WRITE

Specifies write access to the image file. Enables images to be captured to the file. Includes WIM_GENERIC_READ access to enable apply and append operations with existing images.

WIM_GENERIC_MOUNT

Specifies mount access to the image file. Enables images to be mounted with WIMMountImageHandle.

dwCreationDisposition

[in] Specifies which action to take on files that exist, and which action to take when files do not exist. For this parameter you must use one of the following values:

Value Description

WIM_CREATE_NEW

Makes a new image file. If the specified file already exists, the function fails.

WIM_CREATE_ALWAYS

Makes a new image file. If the file exists, the function overwrites the file.

WIM_OPEN_EXISTING

Opens the image file. If the file does not exist, the function fails.

WIM_OPEN_ALWAYS

Opens the image file if it exists. If the file does not exist and the caller requests WIM_GENERIC_WRITE access, the function makes the file.

dwFlagsAndAttributes

[in] Specifies special actions to be taken for the specified file.

Flag Description

WIM_FLAG_VERIFY

Generates data integrity information for new files. Verifies and updates existing files.

WIM_FLAG_SHARE_WRITE

Opens the .wim file in a mode that enables simultaneous reading and writing.

dwCompressionType

[in] Specifies the compression mode to be used for a newly created image file. If the file already exists, then this value is ignored. For this parameter, you must use one of the following values:

Value Description

WIM_COMPRESS_NONE

Capture does not use file compression.

WIM_COMPRESS_XPRESS

Capture uses XPRESS file compression.

WIM_COMPRESS_LZX

Capture uses LZX file compression.

pdwCreationResult

[out] A pointer to a variable that receives one of the following creation-result values. If this information is not required, specify NULL.

Value Description

WIM_CREATED_NEW

The file did not exist and was created.

WIM_OPENED_EXISTING

The file existed and was opened for access.

Return Value

If the function succeeds, the return value is an open handle to the specified image file.

If the function fails, the return value is NULL. To obtain extended error information, call the GetLastError function.

Remarks

Use the WIMCloseHandle function to close the handle returned by the WIMCreateFile function.