共用方式為


File Types Created for Visual C++ Projects

OverviewHow Do IDetails

Starter files are automatically generated for your Visual C++ project, whenever you create one either by using a wizard (such as the MFC AppWizard or the ActiveX ControlWizard) or one of the icons (such as the Application icon) available on the Projects tab of the New dialog.

This topic describes all the types of files that are associated with Visual C++ projects. The actual files included in your project will depend on the project type and the options you select when using a wizard. PROJNAME represents the name of your project.

What kind of files do you want to know more about?

  • Project Files and Makefiles

  • Program or Control source and header files

  • Precompiled header files

  • Resource files

  • Help files

  • Other file options

Project Files and Makefiles

PROJNAME.DSW

This is the workspace file used within the development environment. It organizes all the projects into a single workspace.

PROJNAME.OPT

This is the workspace options file used within the development environment. It stores all the user options you create for your workspace, so that each time you open the project workspace it has the look and feel you want and includes any customizations you have made.

PROJNAME.DSP

This is the project file used within the development environment. In previous versions of Visual C++ this file extension was .MAK. It stores the information specific to your project. There will be a separate .DSP file for each project you create. .DSP files are not compatible with NMAKE. You must export a makefile to build with NMAKE.

PROJNAME.CLW

This file is used by ClassWizard to store information about the classes in your project

PROJNAME.ODL

This file contains the Object Description Language source code for a control type library. This file is used by Visual C++ to generate a type library. The generated library exposes the control’s interface to other Automation clients.

PROJNAME.NCB  This is the No compile Browser file. It contains information generated by the parser which is used by ClassView, WizardBar, and Component Gallery. If the file is accidentally or deliberately deleted, it is automatically regenerated.

README.TXT  A file (located in the parent directory of the project) that describes each file in your project using the actual filenames created by AppWizard or ControlWizard.

Program or Control Source and Header Files

PROJNAME.H

This is the main include file for the program or DLL. It contains all global symbols and #include directives for other header files. It derives the CPrjnameApp class from CWinApp and declares an InitInstance member function. For a control, the CPrjnameApp class is derived from COleControlModule.

PROJNAME.CPP

This file is the main program source file. It creates one object of the class CPrjnameApp (which is derived from CWinApp) and overrides the InitInstance member function.

For executables, CPrjnameApp::InitInstance does several things. It registers document templates, which serve as a connection between documents and views, creates a main frame window, and creates an empty document (or opens a document if one is specified as a command-line argument to the application).

For DLLs and ActiveX (formerly OLE) controls, CProjNameApp::InitInstance registers the control’s object factory with OLE by calling COleObjectFactory::RegisterAll and makes a call to AfxOLEControlInit. In addition, the member function CProjNameApp::ExitInstance is used to unload the control from memory with a call to AfxOleControlTerm.

This file also registers and unregisters the control in the Windows registration database by implementing the DllRegisterServer and DllUnregisterServer functions.

PROJNAMECTL.H, PROJNAMECTL.CPP

These files declare and implement the CProjnameCtrl class. CProjnameCtrl is derived from COleControl, and skeleton implementations of some member functions are defined that initialize, draw, and serialize (load and save) the control. Message, event, and dispatch maps are also defined.

PROJNAMEDLG.CPP, PROJNAMEDLG.H

These files are created if you choose a dialog-based application. The files derive and implement the dialog class, named CProjnameDlg, and include skeleton member functions to initialize a dialog and perform dialog data exchange (DDX). Your About dialog class is also placed in these files instead of in PROJNAME.CPP.

DLGPROXY.CPP, DLGPROXY.H

in a dialog-based program, these are the implementation and header file for the project’s Automation proxy class for the main dialog. This is only used if you have chosen Automation support. This file is one of the templates provided by MFCAPWZ.DLL.

PROJNAMEDOC.CPP, PROJNAMEDOC.H

These files derive and implement the document class, named CProjnameDoc, and include skeleton member functions to initialize a document, serialize (save and load) a document, and implement debugging diagnostics.

PROJNAMESET.H/.CPP   These files are created if you create a program that supports a database and contains the recordset class.

PROJNAMEVIEW.CPP, PROJNAMEVIEW.H

These files derive and implement the view class, named CProjnameView, that is used to display and print the document data. The CProjnameView class is derived from , , , , , , , , or and has skeleton member functions to draw the view and implement debugging diagnostics. If you have enabled support for printing, message-map entries are added for print, print setup, and print preview command messages. These entries call the corresponding member functions in the base view class.

PROJNAMEPPG.H, PROJNAMEPPG.CPP

These files declare and implement the CProjnamePropPage class. CProjnamePropPage is derived from COlePropertyPage and a skeleton member function, DoDataExchange, is provided to implement data exchange and validation.

IPFRAME.CPP, IPFRAME.H

These files are created if the Mini-Server or Full-Server option is selected in AppWizard’s Automation Options page (step 3 of 6). The files derive and implement the in-place frame window class, named CInPlaceFrame, used when the server is in-place activated by a container program.

MAINFRM.CPP, MAINFRM.H

These files derive the CMainFrame class from either (for SDI applications) or (for MDI applications). The CMainFrame class handles the creation of toolbar buttons and the status bar, if the corresponding options are selected in AppWizard’s Application Options page (step 4 of 6).

CHILDFRM.CPP, CHILDFRM.H

These files derive the CChildFrame class from . The CChildFrame class is used for MDI document frame windows. These files are always created if you select the MDI option.

Precompiled Header Files

STDAFX.CPP, STDAFX.H

These files are used to build a precompiled header file PROJNAME.PCH and a precompiled types file STDAFX.OBJ. It is important that you neither define nor undefine any of the _AFX_NO_XXX macros in stdafx.h. See the Knowledge Base article "PRB: Problems Occur When Defining _AFX_NO_XXX". You can find Knowledge Base articles on the MSDN Library CD, or at https://www.microsoft.com/kb/.

Resource Files

PROJNAME.RC, RESOURCE.H

This is the resource file for the project and its header file. The resource file contains the default menu definition and accelerator and string tables for a generic MFC application. It also specifies a default About box and an icon file (RES\PROJNAME.ICO). The resource file includes the file AFXRES.RC for standard Microsoft Foundation class resources. If toolbar support has been specified as an option, it also specifies the toolbar bitmap file (RES\TOOLBAR.BMP).

PROJNAME.RC2

The RC2 file can be included at the top of the RC file in a project.  An RC2 file is useful for including resources used by several different projects.  Instead of having to create the same resources several times for different projects, you can put them in an RC2 file and include the RC2 file into the main RC file.

PROJNAME.DEF

If the project is for a DLL, this is the module-definition file for the project. For a control it provides the name and description of the control, as well as the size of the run-time heap.

RES\PROJNAME.ICO

This is the icon file for the MFC program or control. This icon appears when the application is minimized and is also used in the About box.

RES\TOOLBAR.BMP

This bitmap file is used to represent your program or control in a toolbar or palette. This bitmap is included in the project’s resource file.  The initial toolbar and status bar are constructed in the CMainFrame class.

Help File Option

MAKEHELP.BAT

This batch file (located in the parent directory) is provided only for backward compatibility with older projects. In Visual C++ 6.0, custom build rules are now attached to the .hpj, .cnt and resource.h files, making makehelp.bat obsolete.

This file is used to create the help file PROJNAME.HLP for your program or control.

PROJNAME.HPJ

This file (located in the parent directory) is the Help project file used by the Help compiler to create your program or control’s Help file.

PROJNAME.RTF

This Help file (located in the HLP subdirectory) contains template topics that you can edit and information on customizing your .HPJ file.

PROJNAME.CNT

This file provides the structure for the Contents window in Windows Help.

PRINT.RTF

This file, created if printing support is selected (which it is by default), describes the printing commands and dialog boxes.

BULLET.BMP

This bitmap is used by standard Help file topics to represent bulleted lists.

Other File Options

PROJNAME.LIC

This is the user license file. This file must be present in the same directory as the program or DLL to allow an instance of the control to be created in a design-time environment. Typically, you will distribute this file with a control, but your customers will not distribute it.

PROJNAME.REG

This file is created in two cases. (1) You have selected any Automation server option or an Automation option. (2) You have selected a document file extension (one of the options available in the Advanced Options dialog). The file demonstrates the kind of registration settings the framework will set for you.

RES\ITOOLBAR.BMP

This file is created only if you have chosen any Automation server support and have also chosen the Dockable Toolbar option. The file contains tiled images for the toolbar when the server application is in-place activated inside a container application. The file is similar to the standard RES\TOOLBAR.BMP except that many nonserver commands are removed.