Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Local File Systems
File Management
 WriteEncryptedFileRaw function
WriteEncryptedFileRaw function

Applies to: desktop apps only

Restores (import) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is intended to implement backup and restore functionality, while maintaining files in their encrypted state.

Syntax

DWORD WINAPI WriteEncryptedFileRaw(
  __in      PFE_IMPORT_FUNC pfImportCallback,
  __in_opt  PVOID pvCallbackContext,
  __in      PVOID pvContext
);

Parameters

pfImportCallback [in]

A pointer to the import callback function. The system calls the callback function multiple times, each time passing a buffer that will be filled by the callback function with a portion of backed-up file's data. When the callback function signals that the entire file has been processed, it tells the system that the restore operation is finished. For more information, see ImportCallback.

pvCallbackContext [in, optional]

A pointer to an application-defined and allocated context block. The system passes this pointer to the callback function as a parameter so that the callback function can have access to application-specific data. This can be a structure and can contain any data the application needs, such as the handle to the file that will contain the backup copy of the encrypted file.

pvContext [in]

A pointer to a system-defined context block. The context block is returned by the OpenEncryptedFileRaw function. Do not modify it.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, it returns a nonzero error code defined in Winerror.h. You can use FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic text description of the error.

Remarks

The file being restored is not decrypted; it is restored in its encrypted state.

To back up an encrypted file, call OpenEncryptedFileRaw to open the file. Then call ReadEncryptedFileRaw, passing it the address of an application-defined export callback function. The system calls this callback function multiple times until the entire file's contents have been read and backed up. When the backup is complete, call CloseEncryptedFileRaw to free resources and close the file. See ExportCallback for details about how to declare the export callback function.

To restore an encrypted file, call OpenEncryptedFileRaw, specifying CREATE_FOR_IMPORT in the ulFlags parameter. Then call WriteEncryptedFileRaw, passing it the address of an application-defined import callback function. The system calls this callback function multiple times until the entire file's contents have been read and restored. When the restore is complete, call CloseEncryptedFileRaw to free resources and close the file. See ImportCallback for details about how to declare the export callback function.

This function is intended for restoring only encrypted files; see BackupWrite for restoring unencrypted files.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

WinBase.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

See also

BackupWrite
CloseEncryptedFileRaw
File Encryption
File Management Functions
OpenEncryptedFileRaw
ReadEncryptedFileRaw

 

 

Send comments about this topic to Microsoft

Build date: 4/17/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker