Forget it: just came across the following code posted at:
http://www.123aspx.com/redir.aspx?res=31591
using EnvDTE;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Collections;
namespace VSNET_DesignTimeHelperClass
{
public class TGetApplicationPath {
public string GetPath(){
ControlDesignerHelper cdh = new ControlDesignerHelper();
return(cdh.ProjectProperties("FullPath"));
}
}
public class ControlDesignerHelper
{
private DTE _oDTE = null;
private Hashtable ProjectPropertiesHashTable = new Hashtable();
private ArrayList ProjectPropertiesArrayList = new ArrayList();
public string AllProjectProperties="";
[DllImportAttribute("ole32.dll")]
private static extern int GetRunningObjectTable(int reserved, out UCOMIRunningObjectTable prot);
[DllImportAttribute("ole32.dll")]
private static extern int CreateBindCtx(int reserved, out UCOMIBindCtx ppbc);
//********************
// CONSTRUCTORS
//
/// <summary>
/// Default constructor needed for XML serialization
/// </summary>
public ControlDesignerHelper()
{
init();
}
~ControlDesignerHelper()
{
try { _oDTE = null; }
finally
{ //base.Finalize();
}
}
public string ProjectProperties( string key)
{
if ( ProjectPropertiesHashTable.ContainsKey(key))
return ProjectPropertiesHashTable[key].ToString();
else
return "";
}
private void GetMSDEVFromGIT(string left, string right)
{
int i;
UCOMIRunningObjectTable uCOMIRunningObjectTable;
UCOMIEnumMoniker uCOMIEnumMoniker;
UCOMIBindCtx uCOMIBindCtx;
string str;
object local;
try
{
GetRunningObjectTable(0, out uCOMIRunningObjectTable);
uCOMIRunningObjectTable.EnumRunning(out uCOMIEnumMoniker);
uCOMIEnumMoniker.Reset();
UCOMIMoniker[] uCOMIMonikers = new UCOMIMoniker[1];
while (uCOMIEnumMoniker.Next(1, uCOMIMonikers, out i) == 0)
{
CreateBindCtx(0, out uCOMIBindCtx);
uCOMIMonikers[0].GetDisplayName(uCOMIBindCtx, null, out str);
if (str.StartsWith(left) && str.EndsWith(right))
{
uCOMIRunningObjectTable.GetObject(uCOMIMonikers[0], out local);
_oDTE = (DTE)local;
}
}
}
catch ( Exception e)
{throw e;}
}
public void init()
{
System.Array projs;
EnvDTE.Project proj;
string propValue = "";
ProjectPropertiesHashTable.Clear();
GetMSDEVFromGIT("!VisualStudio.DTE.7",
System.Diagnostics.Process.GetCurrentProcess().Id.ToString());
if (_oDTE != null)
{
projs = (System.Array)_oDTE.ActiveSolutionProjects;
proj = (EnvDTE.Project)projs.GetValue(0);
EnvDTE.Properties pProps = proj.Properties;
for ( int i=1; i <= pProps.Count; i++)
{
propValue = "";
if ( pProps.Item(i).Value != null)
propValue = pProps.Item(i).Value.ToString();
try { ProjectPropertiesHashTable.Add( pProps.Item( i).Name, propValue); }
catch {}
}
// sort the items into a nice easy to read list. This hashtable index starts at one. Arrays
are zero
ProjectPropertiesArrayList = new ArrayList( ProjectPropertiesHashTable.Keys);
ProjectPropertiesArrayList.Sort();
AllProjectProperties = "<BR>ControlDesignerHelper Project Properties";
for ( int k=0; k < ProjectPropertiesArrayList.Count; k++)
AllProjectProperties += "<BR> " + (k+1).ToString() + " <B>" +
ProjectPropertiesArrayList[k].ToString() + "</B> - " +
ProjectPropertiesHashTable[ProjectPropertiesArrayList[k].ToString()].ToString();
}
}
}
}