Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This method retrieves either the absolute path to the object's current working file or, if there is no current working file, the object's default file name prompt.

Syntax

HRESULT GetCurFile(
  LPOLESTR* 
ppszFileName 
);

Parameters

ppszFileName

[out] Points to the location of a pointer to a zero-terminated string containing the path for the current file or the default file name prompt (such as *.txt). If an error occurs, ppszFileNameis set to NULL.

Return Value

S_OK

A valid absolute path was successfully returned.

S_FALSE

The default save prompt was returned.

E_OUTOFMEMORY

The operation failed due to insufficient memory.

E_FAIL

The operation failed due to some reason other than insufficient memory.

Remarks

This method returns the current file name or the default save prompt for the object.

This method allocates memory for the string returned in the ppszFileNameparameter using the IMalloc::Allocmethod. The caller is responsible for calling the IMalloc::Freemethod to free the string. Both the caller and this method use the OLE task allocator provided by a call to CoGetMalloc.

The LPOLESTR type indicates a wide character string (two bytes per character); otherwise, the string has one byte per character.

The file name returned in ppszFileNameis the name specified in a call to IPersistFile::Loadwhen the document was loaded; or in IPersistFile::SaveCompletedif the document was saved to a different file.

If the object does not have a current working file, it should supply the default file name prompt that it would display in a Save As dialog box . For example, the default save prompt for a word processor object could be *.txt.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Notes to Callers

OLE does not call the IPersistFile::GetCurFilemethod. Applications would not call this method unless they are also calling the save methods of this interface.

In saving the object, you can call this method before calling IPersistFile::Saveto determine whether the object has an associated file.

If this method returns S_OK, you can then call IPersistFile::Savewith a NULL file name and a TRUE value for the fRememberparameter to tell the object to save itself to its current file.

If this method returns S_FALSE, you can use the save prompt returned in the ppszFileNameparameter to ask the user to provide a file name. Then, you can call IPersistFile::Savewith the file name that the user entered to perform a Save As operation.

Requirements

Header objidl.h, objidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also