共用方式為


IVsProjectStartupServices.AddStartupService(Guid) Method

Definition

Adds third party service to the list of services to be started when the project is instantiated and ensures that all third party services are started.

public:
 int AddStartupService(Guid % guidService);
public int AddStartupService (ref Guid guidService);
abstract member AddStartupService : Guid -> int
Public Function AddStartupService (ByRef guidService As Guid) As Integer

Parameters

guidService
Guid

[in] GUID object specifying service.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsProjectStartupServices::AddStartupService(  
   [in] REFGUID guidService  
);  

Your implementation of IVsProjectStartupServices.AddStartupService stores the service GUID, then starts it and maintains a pointer to it. You must store any added GUIDs in your project file and read them back in and start the services during project initialization. When your project hierarchy class terminates, you must stop the services, which is accomplished by implementing RemoveStartupService to release the pointers you held.

This functionality is not provided in HierUtil7's CVsHierarchy, which is the basis for Basic Project's CMyProjectHierarchy, so the interface is implemented in the Basic Project sample. The implementation of the above behavior in Basic Project is contained within a member variable to the hierarchy (m_projectStartupServices), which adds the code it takes to remember the services, and start/stop them. The m_projectStartupServices class member is implemented in CVsProjectStartupServices in the file VsProjectStartupServices.h/.cpp, which you can analyze to get an example of proper implementation.

null GUIDS are not added to the list.

Applies to