共用方式為


CWinApp::OpenDocumentFile

virtualCDocument*OpenDocumentFile(LPCTSTRlpszFileName**);**

Return Value

A pointer to a CDocument if successful; otherwise NULL.

Parameters

lpszFileName

The name of the file to be opened.

Remarks

The framework calls this member function to open the named CDocument file for the application. If a document with that name is already open, the first frame window that contains that document will be activated. If an application supports multiple document templates, the framework uses file extension to find the appropriate document template to attempt to load the document. If successful, the document template then creates a frame window and view for the document.

Example

BOOL CMyApp::InitInstance()
{
   // ...
   if (m_lpCmdLine[0] == '\0')
   {
      // Create a new (empty) document.
      OnFileNew();
   }
   else
   {
      // Open a file passed as the first command line parameter.
      OpenDocumentFile(m_lpCmdLine);
   }

   // ...
}

CWinApp OverviewClass MembersHierarchy Chart