This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here
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.
An automation consumer presumes to be able to call Solution("
<UniqueProjName>") and ProjectItems (
n) where n is an index number for obtaining a specific project in the solution. 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
HRESULT GetProperty (
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.
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.