Assembly: Microsoft.VisualStudio.Shell.Interop (in microsoft.visualstudio.shell.interop.dll)
int CreateProject ( [InAttribute] ref Guid rguidProjectType, [InAttribute] string lpszMoniker, [InAttribute] string lpszLocation, [InAttribute] string lpszName, [InAttribute] uint grfCreateFlags, [InAttribute] ref Guid iidProject, out IntPtr ppProject )
int CreateProject ( /** @attribute InAttribute() */ /** @ref */ Guid rguidProjectType, /** @attribute InAttribute() */ String lpszMoniker, /** @attribute InAttribute() */ String lpszLocation, /** @attribute InAttribute() */ String lpszName, /** @attribute InAttribute() */ UInt32 grfCreateFlags, /** @attribute InAttribute() */ /** @ref */ Guid iidProject, /** @attribute OutAttribute() */ /** @ref */ IntPtr ppProject )
[in] Unique identifier for the project type obtained when the project factory is registered. Can be GUID_NULL, if a value for lpszMoniker is specified. This parameter indicates the type of project to create or to add to the solution. If the value is GUID_NULL, then the environment attempts to determine the project type based on the extension of the file.
[in] Pointer to the file moniker. If this method is used to open a project, then specify the path to the project on disk (including project name and file extension). If the method is being used to create a project, then specify the full path to the template file that will be cloned.
[in] Pointer to the path specifying the location for the new project. This parameter is used only when grfCreateFlags parameter; otherwise it is a null reference (Nothing in Visual Basic) (for open project). If the project is a directory-based project, then this is the directory for the project. The project file for the project is saved in this directory. If the project is not directory-based, then this location is used only to save the project file and perhaps as the default directory for newly created items. The szLocation parameter is defined to always include the trailing slash (\). Then, the project factory does not have to look for paths that look like "C:\" versus "C:\MyProjects\Project1" when constructing the path name of the project file.is specified for the
[in] Pointer to the new project name. This parameter is used only when CPF_CLONEFILE is specified for the grfCreateFlags parameter; otherwise it is a null reference (Nothing in Visual Basic) (for open project). The project name does not include a file extension.
[in] Controls how a project is created or opened. For a list of grfCreateFlags values, see .
[in] Interface identifier of the returned ppProject. This value can be iid_NULL to specify no return.
[out, iid_is(iidProject)] Pointer to the newly created project.
Return ValueIf the method succeeds, it returns . If it fails, it returns an error code.
HRESULT IVsSolution::CreateProject( [in] REFGUID rguidProjectType, [in] LPCOLESTR lpszMoniker, [in] LPCOLESTR lpszLocation, [in] LPCOLESTR lpszName, [in] VSCREATEPROJFLAGS grfCreateFlags, [in] REFIID iidProject, [out, iid_is(iidProject)] void **ppProject );
If you are using the IVsSolution,CreateProject method to create a new project, then provide values for lpszMoniker, lpszLocation, and lpszName. If you are using this method to open an existing project, then lpszLocation, and lpszName are a null reference (Nothing in Visual Basic).
This method handles creating and opening project files only and does not support the opening of a solution file, that is, files with a SLN, DSW, or VBG extension. Opening of these file types is handled by themethod.
Creating a new project is accomplished by cloning an existing project that is empty. The environment determines which VSPackage calls this method based on the file extension.
If both CPF_CLONEFILE andare specified, the project overwrites the destination project file. If CPF_OVERWRITE is not specified, a specific HRESULT, , is returned from this method. The environment then displays the This Project Already Exists dialog box. If the user chooses to overwrite the project file, the environment calls the method again, specifying both CPF_CLONEFILE and CPF_OVERWRITE.
This method can display the user interface unless theflag is specified. This method should not report error messages to the user. This method uses the standard error-reporting conventions of the environment; it calls the method to record any error that occurs, and then returns an error HRESULT. The caller ultimately calls the method to display the error message.
When this method returns an error HRESULT, it calls the SetErrorInfo method to supply information about which VSPackage or project could not be loaded and why. The caller of this method can use the ReportErrorInfo method to show this error message to the user.