本文整理汇总了C#中IVsSolution.CreateProject方法的典型用法代码示例。如果您正苦于以下问题:C# IVsSolution.CreateProject方法的具体用法?C# IVsSolution.CreateProject怎么用?C# IVsSolution.CreateProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsSolution
的用法示例。
在下文中一共展示了IVsSolution.CreateProject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSolutionItem
public static void AddSolutionItem(IVsSolution solution, string fileName)
{
uint itemId = DteHelper2.FindItemByName(
solution as IVsHierarchy, "Solution Items");
IntPtr ptr = IntPtr.Zero;
Guid solutionFolderGuid = new Guid("2150E333-8FDC-42a3-9474-1A3956D46DE8");
Guid iidProject = typeof(IVsHierarchy).GUID;
int res = solution.CreateProject(
ref solutionFolderGuid,
null,
null,
"Solution Items",
0,
ref iidProject,
out ptr);
if(ptr != IntPtr.Zero)
{
IVsHierarchy hierarchy = (IVsHierarchy)Marshal.GetObjectForIUnknown(ptr);
Guid projGuid;
hierarchy.GetGuidProperty(
VSConstants.VSITEMID_ROOT,
(int)__VSHPROPID.VSHPROPID_ProjectIDGuid,
out projGuid);
ProjectNode node = new ProjectNode(solution, projGuid);
node.AddItem(fileName);
}
}
示例2: RunFinished
public void RunFinished()
{
sln = ((IVsSolution)Package.GetGlobalService(typeof(SVsSolution)));
ServiceProvider serviceProvider = new ServiceProvider(dte as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
string projectGuid = null;
using (XmlReader projectReader = XmlReader.Create(fileName))
{
projectReader.MoveToContent();
object nodeName = projectReader.NameTable.Add("ProjectGuid");
while (projectReader.Read())
{
if (Object.Equals(projectReader.LocalName, nodeName))
{
projectGuid = projectReader.ReadElementContentAsString();
break;
}
}
}
IVsHierarchy hier = VsShellUtilities.GetHierarchy(serviceProvider, new Guid(projectGuid));
sln.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, hier, 0);
String bistroPath = (String)Registry.LocalMachine.CreateSubKey(@"Software\Hill30\Bistro").GetValue("InstallDir");
#if VS2008
String ndjangoPath = (String)Registry.LocalMachine.CreateSubKey(@"Software\Hill30\NDjango").GetValue("InstallDir2008");
#elif VS2010
String ndjangoPath = (String)Registry.LocalMachine.CreateSubKey(@"Software\Hill30\NDjango").GetValue("InstallDir2010");
#endif
StreamReader reader = new StreamReader(fileName);
string content = reader.ReadToEnd();
reader.Close();
content = content.Replace(BISTRODIR, (bistroPath == null) ? BISTRODIR : Path.GetFullPath(bistroPath)).
Replace(NDJANGODIR, (ndjangoPath == null) ? NDJANGODIR : Path.GetFullPath(ndjangoPath));
StreamWriter sw = new StreamWriter(fileName);
sw.Write(content);
sw.Close();
IntPtr ppProject = IntPtr.Zero;
Guid guid1 = new Guid();
Guid guid2 = new Guid();
sln.CreateProject(ref guid1, fileName, null, null, (uint)__VSCREATEPROJFLAGS.CPF_OPENFILE, ref guid2, out ppProject);
}