Re: com interop

From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 06/22/04


Date: Tue, 22 Jun 2004 12:47:27 -0400

Frazer,

    I am not sure what you are trying to do. The example you give deals
with showing a movie, and yet, you want the spell checker from word? If you
want to access Word functionality, you should be able to just add a
reference to the Word object library, and then access what you wish. In
this case, I would imagine the spell checker capability is something that
the Document object exposes.

    Hope this helps.

-- 
               - Nicholas Paldino [.NET/C# MVP]
               - mvp@spam.guard.caspershouse.com
"frazer" <ichor@hotmail.com> wrote in message
news:uT3NP59VEHA.2840@TK2MSFTNGP11.phx.gbl...
> 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

  • com interop
    ... i need to know what interface ms-word's spell checker uses. ... void Pause(); ... This method collects the file name of an AVI to ... // DisplayUsage(); ...
    (microsoft.public.dotnet.languages.csharp)
  • 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: Delegates VS interfaces - some confusion
    ... one member of the interface, whereas with a delegate you can specify ... delegate void Func; ... algorithm not changing at run time and how that makes it intrinsic to ...
    (microsoft.public.dotnet.languages.csharp)
  • System.TypeLoadException and explicit interface implementation
    ... an assembly that is simply declaring an interface and a value type used ... Method DoSomething in type TestClass from assembly ... In the console application ... void DoSomething(); ...
    (microsoft.public.dotnet.languages.vc)