> Erick Thompson spake:
>
> How would I go about using the IFilter[1] interface from C#? From what I
> gather, it's not an automation interface (== not a COM object?),
> so I'm not
> sure where to start.
>
> Thanks,
> Erick
>
> [1]
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/i
ndexsrv/ixrefint_9sfm.asp
If there is a type library, you could use the tlbimp utility to generate a
proxy assembly.
If there is no type library, you can create your own Runtime Callable
Wrappers (RCWs).
Here is an RCW for IClassFactory:
===>
[ComVisible(true)]
[Guid("00000001-0000-0000-c000-000000000046")]
[CLSCompliant(false)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IClassFactory
{
[PreserveSig]
Int32 CreateInstance(
IntPtr pUnkOuter,
[In] ref Guid refiid,
IntPtr ppvObject);
void LockServer(
[MarshalAs(UnmanagedType.Bool)] Boolean fLock);
}
<===
And here is an RCW for IPersistStreamInit:
===>
[ComVisible(true)]
[Guid("7fd52380-4e07-101b-ae2d-08002b2ec713")]
[CLSCompliant(false)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistStreamInit
{
void GetClassID(out Guid pClassID);
[PreserveSig]
Int32 IsDirty();
void Load(IStream stream);
void Save(IStream stream, [MarshalAs(UnmanagedType.Bool)] Boolean
fClearDirty);
UInt64 GetSizeMax();
void InitNew();
}
<===
If you call a DLL routine to get your interface pointer, setup your p/invoke
as follows:
// P/Invoke functions
[DllImport("urlmon.dll")]
private static extern Int32 CoInternetGetSession(
UInt32 dwSessionMode,
ref IInternetSession ppIInternetSession,
UInt32 dwReserved);
--
Peter
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.