com interop

From: frazer (ichor_at_hotmail.com)
Date: 06/21/04


Date: Tue, 22 Jun 2004 08:27:11 +1000

hi,
i need to know what interface ms-word's spell checker uses.
i got this example from msdn, that makes use of com interop.
i was wondering how do i get the interface IMediaContorl or any other (i am
interested in ms-words spell checker interface. )
thnx

// interop2.cs
using System;
using System.Runtime.InteropServices;

namespace QuartzTypeLib
{
 // Declare IMediaControl as a COM interface which
 // derives from IDispatch interface:
 [Guid("56A868B1-0AD4-11CE-B03A-0020AF0BA770"),
 InterfaceType(ComInterfaceType.InterfaceIsDual)]
 interface IMediaControl // Cannot list any base interfaces here
 {
  // Note that IUnknown Interface members are NOT listed here:

  void Run();
  void Pause();

  void Stop();

  void GetState( [In] int msTimeout, [Out] out int pfs);

  void RenderFile(
   [In, MarshalAs(UnmanagedType.BStr)] string strFilename);

  void AddSourceFilter(
   [In, MarshalAs(UnmanagedType.BStr)] string strFilename,
   [Out, MarshalAs(UnmanagedType.Interface)]
   out object ppUnk);

  [return: MarshalAs(UnmanagedType.Interface)]
  object FilterCollection();

  [return: MarshalAs(UnmanagedType.Interface)]
  object RegFilterCollection();

  void StopWhenReady();
 }
 // Declare FilgraphManager as a COM coclass:
 [ComImport, Guid("E436EBB3-524F-11CE-9F53-0020AF0BA770")]
 class FilgraphManager // Cannot have a base class or
  // interface list here.
 {
  // Cannot have any members here
  // NOTE that the C# compiler will add a default constructor
  // for you (no parameters).
 }
}

class MainClass
{
 /**********************************************************
   Abstract: This method collects the file name of an AVI to
   show then creates an instance of the Quartz COM object.
   To show the AVI, the program calls RenderFile and Run on
   IMediaControl. Quartz uses its own thread and window to
   display the AVI.The main thread blocks on a ReadLine until
   the user presses ENTER.
   Input Parameters: the location of the AVI file it is
   going to display
   Returns: void
   *************************************************************/

 public static void Main(string[] args)
 {
  // Check to see if the user passed in a filename:
// if (args.Length != 1)
// {
// DisplayUsage();
// return;
// }
//
// if (args[0] == "/?")
// {
// DisplayUsage();
// return;
// }

  String filename = "movie.avi";//args[0];

  // Check to see if the file exists
  if (!System.IO.File.Exists(filename))
  {
   Console.WriteLine("File " + filename + " not found.");
   DisplayUsage();
   return;
  }

  // Create instance of Quartz
  // (Calls CoCreateInstance(E436EBB3-524F-11CE-9F53-0020AF0BA770,
  // NULL, CLSCTX_ALL, IID_IUnknown,
  // &graphManager).):
  try
  {
   QuartzTypeLib.FilgraphManager graphManager =
    new QuartzTypeLib.FilgraphManager();

   // QueryInterface for the IMediaControl interface:
   QuartzTypeLib.IMediaControl mc =
    (QuartzTypeLib.IMediaControl)graphManager;

   // Call some methods on a COM interface.
   // Pass in file to RenderFile method on COM object.
   mc.RenderFile(filename);

   // Show file.
   mc.Run();
  }
  catch(Exception ex)
  {
   Console.WriteLine("Unexpected COM exception: " + ex.Message);
  }
  // Wait for completion.
  Console.WriteLine("Press Enter to continue.");
  Console.ReadLine();
 }

 private static void DisplayUsage()
 {
  // User did not provide enough parameters.
  // Display usage.
  Console.WriteLine("VideoPlayer: Plays AVI files.");
  Console.WriteLine("Usage: VIDEOPLAYER.EXE filename");
  Console.WriteLine("where filename is the full path and");
  Console.WriteLine("file name of the AVI to display.");
 }
}



Relevant Pages

  • Problem getting events from C# to VJ++
    ... interface IWeatherEvents: IUnknown ... public delegate void WeatherChangedDelegate(int nTemperature); ... // float Temperature ... private float m_fTemperature = 0; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question about Java updates installed?
    ... public long add(int a, int b) ... either encapsulate the add method in an interface and then ... void test() throws Exception { ... A multicast delegate was also possible. ...
    (comp.lang.java.advocacy)
  • Re: Ribbon and a checkbox (C++ ATL)
    ... public void Ribbon_onAction ... When I do a C# addin that has to support Outlook 2003 and later I use ribbon interface definitions based on a blog article by Andrew Whitechapel of the VSTO team in a RibbonInterop class and handle the callbacks in a RibbonX class. ... MethodCodeType = MethodCodeType.Runtime), DispId] get;} ... string Tag { ...
    (microsoft.public.outlook.program_addins)
  • Re: Generic Repository ... How can I do this?
    ... Alternatively, if you can generalize the LINQ operations by using some base class or interface that, for example, the "Articles" class inherits or implements, as well as a base class or interface that the object class itself inherits or implements, then you could create a base class that takes advantage of that, so that the type-specific version only has to add a little more functionality. ... void Delete; ... I preserved your convention in my example for the sake of continuity, but if you find yourself needing to distinguish between a local variable and an argument, you should do so with something besides an underscore. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: com interop
    ... with showing a movie, and yet, you want the spell checker from word? ... > i need to know what interface ms-word's spell checker uses. ... > void Pause(); ... > // DisplayUsage(); ...
    (microsoft.public.dotnet.languages.csharp)