CPackage::StoreFile

The CPackage::StoreFile function stores the specified file in the package.

BOOL StoreFile(
DWORD dwFileFlags, // file options
DWORD dwTargetPlatform, // file platform
LPCTSTR lpszOldFile, // old file name
LPCTSTR lpszNewFile, // new file name
LPCTSTR lpszInstallPath, // installation path
LPCTSTR lpszFileName // file name in package
);

Parameters

dwFileFlags
[in] A value that specifies one or more options.
 
The following values may be used:
Value Description
PACKAGE_FILE_FLAG_SHARED The file is shared and may be locked on the target system. This should be specified for shared components and libraries which may be in use at the time that the patch package is applied.
PACKAGE_FILE_FLAG_REGISTER The file is a self-registering COM object and should be registered when the file is extracted. If this option is specified for a patch file, the file is registered after the patch is applied.
PACKAGE_FILE_FLAG_REPLACE When this file is extracted from the package, it should replace any existing file with the same name. If this flag is not set and the file already exists, an error will be returned when it is extracted.
dwTargetPlatform
[in] Specifies the target platform for the file.
 
This may be one of the following values:
 
Value Description
PACKAGE_FILE_PLATFORM_DEFAULT The file may be applied on all Windows platforms. This is the same as specifying a value of PACKAGE_FILE_PLATFORM_WINDOWS.
PACKAGE_FILE_PLATFORM_WIN95 The file may be applied to a system running Windows 95.
PACKAGE_FILE_PLATFORM_WIN98 The file may be applied to a system running Windows 98 or Windows 98 SE.
PACKAGE_FILE_PLATFORM_WINME The file may be applied to a system running Windows ME.
PACKAGE_FILE_PLATFORM_WINNT40 The file may be applied to a system running Windows NT 4.0.
PACKAGE_FILE_PLATFORM_WIN2000 The file may be applied to a system running Windows 2000.
PACKAGE_FILE_PLATFORM_WINXP The file may be applied to a system running Windows XP.
PACKAGE_FILE_PLATFORM_WIN2003 The files may be applied to a system running Windows Server 2003.
In addition to the above platform-specific values, there are predefined values which specify platform groups:
 
Value Description
PACKAGE_FILE_PLATFORM_WIN32 The file may be applied to any 32-bit version of the Windows operating system.
PACKAGE_FILE_PLATFORM_WIN9X The file may be applied to any system running Windows 95, Windows 98 or Windows ME. The file will not be applied on a system running Windows NT, Windows 2000 or Windows XP.
PACKAGE_FILE_PLATFORM_WINNT The file may be applied to any system running Windows NT, Windows 2000 or Windows XP. The file will not be applied on a system running Windows 95, Windows 98 or Windows ME.
PACKAGE_FILE_PLATFORM_WINDOWS The files may be applied to any system running any version of Microsoft Windows.
lpszOldFile
[in] A pointer to a null-terminated string which specifies the original version of the file to be updated. If a NULL pointer is specified, then this is considered to be a new file to be created on the target system.
 
lpszNewFile
[in] A pointer to a null-terminated string which specifies the updated version of the file. If a NULL pointer is specified, then the old file is removed from the target system.
 
lpszInstallPath
[in] A pointer to a null-terminated string which specifies the location on the target system where the file will be created, modified or deleted. This pointer may be NULL, in which case the files will be installed in the default installation directory on the target system.
 
lpszFileName
[in] A pointer to a null-terminated string which specifies the name of the file on the target system. This may include a relative path in which case it is installed under the directory specified by lpszInstallPath.

Return Values

If the CPackage::StoreFile function succeeds, it will return a non-zero value.

If the function fails, it will return a value of zero. To get extended error information, call GetLastError.

Remarks

The file names may not include wildcard characters. To add multiple files to the package, use the CPackage::Update function.

To ensure that a file is always created, regardless of whether or not it currently exists on the target system, the PACKAGE_FILE_FLAG_REPLACE option must be specified.

If the file is a Windows PE module with a version resource that includes the OleSelfRegister string value, this file is automatically considered to be a self-registering component.

This function will return an error if the package has been opened for read-only access.

Requirements

Windows NT/2000/XP: Requires Windows NT 4.0 SP3 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Include apatch.h.
Library: Use apatch32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP.

See Also

CPackage::ExtractFile