建模项目

The next step in providing automation for your project is to implement the standard project objects: the Projects and ProjectItems collections; the Project and ProjectItem objects; and the remaining objects unique to your implementation. These standard objects are defined in Dteinternal.h file. An implementation of the standard objects is provided in the BscPrj sample. You can use these classes as models to create your own standard project objects that stand side-by-side with project objects from other project types.

自动化使用者假设可以调用 Solution("<UniqueProjName>")和 ProjectItems (n) n 是用于获取的特定项的索引号在解决方案的位置。 Making this automation call causes the environment to call GetProperty on the appropriate project hierarchy, passing VSITEMID_ROOT as the ItemID parameter and VSHPROPID_ExtObject as VSHPROPID parameter. IVsHierarchy::GetProperty returns an IDispatch pointer to the automation object providing the core Project interface, which you have implemented.

The following is the syntax of IVsHierarchy::GetProperty.

HRESULT GetProperty (

VSITEMID itemid,

VSHPROPID propid,

VARIANT *pvar

);

Projects accommodate nesting and use collections to create groups of project items. The hierarchy looks like this.

Projects
  |– Project
      |– ProjectItems (a collection of ProjectItem)
          |– ProjectItem (single object) or ProjectItems (another collection)

Nesting means that a ProjectItem object can be ProjectItems collection at the same time because a ProjectItems collection can contain the nested objects. The Basic Project sample does not demonstrate this nesting. By implementing the Project object, you participate in the tree-like structure that characterizes the design of the overall automation model.

The project automation follows the path in the following diagram.

Project automation

Visual Studio 项目对象

If you do not implement a Project object, the environment will still return a generic Project object that contains only the name of the project.

请参见

参考

Projects

ProjectItem

ProjectItems