Re: com interop
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 06/22/04
- Next message: Brian Conway: "Re: Looping through a datagrid"
- Previous message: Saga: "Re: vb.net vs c#.net, the SQL"
- In reply to: frazer: "com interop"
- Next in thread: frazer: "Re: com interop"
- Reply: frazer: "Re: com interop"
- Messages sorted by: [ date ] [ thread ]
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.");
> }
> }
>
>
- Next message: Brian Conway: "Re: Looping through a datagrid"
- Previous message: Saga: "Re: vb.net vs c#.net, the SQL"
- In reply to: frazer: "com interop"
- Next in thread: frazer: "Re: com interop"
- Reply: frazer: "Re: com interop"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|