/// <summary> /// Returns the count of running Publisher.Application instances that passed a predicate filter /// </summary> /// <returns>count of running application</returns> public static int GetActiveInstancesCount() { var sequence = ProxyService.GetActiveInstances <Application>("Publisher", "Application"); int result = sequence.Count; sequence.Dispose(); return(result); }
/// <summary> /// Returns the count of running Outlook.Application instances that passed a predicate filter /// </summary> /// <param name="predicate">filter predicate</param> /// <returns>count of running application</returns> public static int GetActiveInstancesCount(Func <Application, bool> predicate) { var sequence = ProxyService.GetActiveInstances <Application>("Outlook", "Application", predicate); int result = sequence.Count; sequence.Dispose(); return(result); }
public void Run() { // In some situations you want use NetOffice with an already running application. // this tutorial shows how its possible. // 1) // // GetActiveInstance take the first instance in memory Excel.Application application = ProxyService.GetActiveInstance <Excel.Application>(); if (null != application) { application.Dispose(); } // 2) // // GetActiveInstances takes all instances in memory var applications = ProxyService.GetActiveInstances <Excel.Application>(); applications.Dispose(); // 3) // // Use special ctor to try access a running application first // and if its failed create a new application application = new Excel.ApplicationClass(new Core(), true); // quit only if its a new application if (!application.FromProxyService) { application.Quit(); } application.Dispose(); // 4) // // Creates instance from interop proxy Type interopType = Type.GetTypeFromProgID("Excel.Application"); object proxy = Activator.CreateInstance(interopType); application = COMObject.Create <Excel.Application>(proxy); application.Quit(); application.Dispose(); HostApplication.ShowFinishDialog(); }
/// <summary> /// Returns all running Outlook.Application instances from the environment/system that passed a predicate filter /// </summary> /// <param name="predicate">filter predicate</param> /// <returns>Outlook.Application sequence</returns> public static IDisposableSequence <Application> GetActiveInstances(Func <Application, bool> predicate) { return(ProxyService.GetActiveInstances <Application>("Outlook", "Application", predicate)); }
/// <summary> /// Returns all running Outlook.Application instances from the environment/system /// </summary> /// <returns>Outlook.Application sequence</returns> public static IDisposableSequence <Application> GetActiveInstances() { return(ProxyService.GetActiveInstances <Application>("Outlook", "Application")); }
/// <summary> /// Returns all running Excel.Worksheet instances from the environment/system /// </summary> /// <returns>Excel.Worksheet sequence</returns> public static IDisposableSequence <Application> GetActiveInstances() { return(ProxyService.GetActiveInstances <Application>("Excel", "Worksheet")); }
/// <summary> /// Returns all running Word.Document instances from the environment/system /// </summary> /// <returns>Word.Document sequence</returns> public static IDisposableSequence <Application> GetActiveInstances() { return(ProxyService.GetActiveInstances <Application>("Word", "Document")); }