IInitializeWithFile::Initialize method (propsys.h)

Initializes a handler with a file path.

Syntax

HRESULT Initialize(
  [in] LPCWSTR pszFilePath,
  [in] DWORD   grfMode
);

Parameters

[in] pszFilePath

Type: LPCWSTR

A pointer to a buffer that contains the file path as a null-terminated Unicode string.

[in] grfMode

Type: DWORD

One of the following STGM values that indicates the access mode for pszFilePath.

STGM_READ

The file indicated by IInitializeWithFile::Initialize is read-only.

STGM_READWRITE

The file indicated by IInitializeWithFile::Initialize can be read from and written to.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Initialize is preferred to this method because of its ability to use files that are not accessible through a Win32 path, such as the contents of a compressed file with a .zip file name extension. Use IInitializeWithFile::Initialize only when the API used by the handler to access the file accepts file paths only.

The file pointed to by pszFilePath must remain open for the lifetime of the handler or until IPropertyStore::Commit is called.

If the file cannot be opened according to the method's parameter values, this method returns a suitable error code.

A handler instance should be initialized only once in its lifetime. Attempts by the calling application to reinitialize the handler should result in the error HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED).

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header propsys.h