Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Display an install date and a print date. Pin
Heath Stewart25-May-04 9:49
protectorHeath Stewart25-May-04 9:49 
GeneralRe: Display an install date and a print date. Pin
kornstyle25-May-04 11:03
kornstyle25-May-04 11:03 
QuestionCan I send mouse clicks to another application? Pin
ekolis25-May-04 8:52
ekolis25-May-04 8:52 
AnswerRe: Can I send mouse clicks to another application? Pin
Heath Stewart25-May-04 9:43
protectorHeath Stewart25-May-04 9:43 
GeneralRe: Can I send mouse clicks to another application? Pin
ekolis25-May-04 15:05
ekolis25-May-04 15:05 
GeneralRe: Can I send mouse clicks to another application? Pin
Dave Kreskowiak25-May-04 17:14
mveDave Kreskowiak25-May-04 17:14 
GeneralRe: Can I send mouse clicks to another application? Pin
Heath Stewart26-May-04 2:57
protectorHeath Stewart26-May-04 2:57 
GeneralInterop with MSDev 6.0 running instanceS Pin
Eric Marchesin25-May-04 8:52
Eric Marchesin25-May-04 8:52 
Hello,

I've developped a Windows Application that needs to know the list of all the files that are opened in all running instances of MSDev (Visual Studio 6.0).
Thanks to Mr H. Stewart I succeeded in getting the files of one instance : the first that has been registered in the ROT (running objects table)... but despite having tried many differents ways, I can't manage to get the files opened in the other instances.

Hereafter is the latest version of my code which uses iteration through UCOMIEnumMoniker and calls UCOMIRunningObjectTable.GetObject for each UCOMIMoniker. Even so, these objects are seemingly all representing the same first MSDev instance...

using Microsoft.Win32; // to access the reg
using DSSharedObjects; // generated with : tlbimp.exe DEVSHL.DLL

public static string[] ImportFilesFromMSDev()
{
	ArrayList AL = new ArrayList();
	try
	{
		object[] Objects = GetActiveObjects("MSDEV.APPLICATION");
		foreach( object Obj in Objects )
		{
		DSSharedObjects.IApplication App = Obj as DSSharedObjects.IApplication;
		if ( App==null ) continue;
		DSSharedObjects.IDocuments Docs = App.Documents as DSSharedObjects.IDocuments;
		if ( Docs!=null && Docs.Count>0 )
			foreach ( DSSharedObjects.IGenericDocument D in Docs ) AL.Add(D.FullName);
		}
	}
	catch{}
	return AL.ToArray(typeof(string)) as string[];
}


[DllImport("ole32.dll")]
private static extern int GetRunningObjectTable(int reserved, out UCOMIRunningObjectTable prot);

[DllImport("ole32.dll")]
private static extern int CreateBindCtx(int reserved, out UCOMIBindCtx ppbc);


private static object[] GetActiveObjects(string ProgId)
{
	ArrayList objs = new ArrayList();
	UCOMIRunningObjectTable prot;
	UCOMIEnumMoniker pMonkEnum;

	GetRunningObjectTable(0,out prot);
	prot.EnumRunning(out pMonkEnum);
	pMonkEnum.Reset();
	int fetched;

	UCOMIMoniker []pmon = new UCOMIMoniker[1];
	while( pMonkEnum.Next(1, pmon, out fetched)==0 )
	{
		UCOMIBindCtx pCtx;
		CreateBindCtx(0, out pCtx);
		string str;
		pmon[0].GetDisplayName(pCtx,null,out str);
		
		try
		{
		RegistryKey Clef = Registry.ClassesRoot;
		if ( Clef!=null )
		{
			int P1 = str.IndexOf('{');
			int P2 = str.IndexOf('}');
			if ( P1>0 && P2>P1 )
			{
				string ClassHive = @"\CLSID\"+str.Substring(P1,P2);
				RegistryKey SK = Clef.OpenSubKey(ClassHive+@"\ProgID", false);
				if ( SK!=null )
				{
					string Val = SK.GetValue("") as string;
					if ( Val!=null && ProgId==Val )
					{
						object objReturnObject;
						prot.GetObject(pmon[0],out objReturnObject);
						objs.Add(objReturnObject);
					}
				}
			}
		}
		}
		catch {}
	}
	return objs.ToArray();
}


Any idea ??
Best regards,

- Éric -
GeneralRe: Interop with MSDev 6.0 running instanceS Pin
Heath Stewart25-May-04 10:36
protectorHeath Stewart25-May-04 10:36 
GeneralRe: Interop with MSDev 6.0 running instanceS Pin
Eric Marchesin25-May-04 11:15
Eric Marchesin25-May-04 11:15 
GeneralRe: Interop with MSDev 6.0 running instanceS Pin
Heath Stewart25-May-04 11:20
protectorHeath Stewart25-May-04 11:20 
GeneralRe: Interop with MSDev 6.0 running instanceS Pin
Eric Marchesin25-May-04 11:32
Eric Marchesin25-May-04 11:32 
GeneralRe: Interop with MSDev 6.0 running instanceS Pin
Heath Stewart25-May-04 12:21
protectorHeath Stewart25-May-04 12:21 
GeneralRe: Interop with MSDev 6.0 running instanceS Pin
Eric Marchesin25-May-04 12:32
Eric Marchesin25-May-04 12:32 
QuestionSoap extension with command line client? Pin
shining_star7725-May-04 8:51
shining_star7725-May-04 8:51 
AnswerRe: Soap extension with command line client? Pin
Heath Stewart25-May-04 9:37
protectorHeath Stewart25-May-04 9:37 
QuestionHow to use Pin
IamADotNetGuy25-May-04 7:57
IamADotNetGuy25-May-04 7:57 
AnswerRe: How to use Pin
Heath Stewart25-May-04 8:11
protectorHeath Stewart25-May-04 8:11 
GeneralRe: How to use Pin
IamADotNetGuy25-May-04 8:14
IamADotNetGuy25-May-04 8:14 
GeneralRe: How to use Pin
Heath Stewart25-May-04 8:18
protectorHeath Stewart25-May-04 8:18 
GeneralRe: How to use Pin
IamADotNetGuy25-May-04 8:22
IamADotNetGuy25-May-04 8:22 
GeneralRe: How to use Pin
Heath Stewart25-May-04 8:28
protectorHeath Stewart25-May-04 8:28 
GeneralRe: How to use Pin
IamADotNetGuy25-May-04 8:46
IamADotNetGuy25-May-04 8:46 
GeneralRe: How to use Pin
Heath Stewart25-May-04 9:22
protectorHeath Stewart25-May-04 9:22 
GeneralLogout problem Pin
IamADotNetGuy28-May-04 5:42
IamADotNetGuy28-May-04 5:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.