I'm now going through and filling out the RCW for IFilter. The next method
is GetValue, with the following signature.

SCODE GetValue(
  PROPVARIANT ** ppPropValue
);
ppPropValue
[out] Pointer to an output variable that receives a pointer to the
PROPVARIANT structure that contains the value-type property.

Now, the PROPVARIANT is a huge mess of an object, and it appears under the
general COM section of the SDK. I assume that it's related to the VB variant
datatype. Is there a .net version/wrapper for this struct already defined
somewhere?

Thanks,
Erick

----- Original Message -----
From: "Erick Thompson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 14, 2002 1:12 PM
Subject: Re: [DOTNET] RCW for IFilter and LoadIFilter


> Peter,
>
> Thanks for your great suggestions. I eventually ended up using the last
> method, the one that explicitly created the char array using AllocHGlobal.
> Is this method going to impact performance at all, or is using
AllocHGlobal
> actually going to speed things up?
>
> Thanks,
> Erick
>
> ----- Original Message -----
> From: "Peter Stephens" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, May 14, 2002 12:57 AM
> Subject: Re: [DOTNET] RCW for IFilter and LoadIFilter
>
>
> > >            [PreserveSig]
> > >            int GetText(
> > >                       [MarshalAs(UnmanagedType.U4)]
> > >                       out UInt32 pcwcBuffer,
> > >                       [MarshalAs(UnmanagedType.LPWStr)]
> > >                       out string awcBuffer
> > >            );
> >
> > Just looking at the docs for IFilter::GetText your interface is a little
> > off.
> >
> > pcwcBuffer is not out, but is in/out. In other words it is ref.
> >
> > Also note that awcBuffer is not a zero terminated string. It is just a
> > buffer. You might use a Char[] array instead of a String.
> >
> > Setup your interface like so:
> >
> > [PreserveSig]
> > Int32 GetText(ref UInt32 pcwcBuffer,
> >         [MarshalAs(Unmanaged.LPArray, SizeParamIndex = 0)]
> >         out Char[] awcBuffer)
> >
> > This is untested and might not work, but it should get you closer.
> >
> > If this does not work, you might try this:
> >
> > Int32 GetText(ref UInt32 pcwcBuffer,
> >         [MarshalAs(Unmanaged.LPArray, SizeConst = 1024)]
> >         ref Char[] awcBuffer);
> >
> > And then call it like this:
> > Char[] buff = new Char[1024];
> > UInt32 buffSize = 1024;
> > Int32 ret = MyIFilter.GetText(ref buffSize, ref buff);
> >
> > You can be more precise with marshaling by using an IntPtr.
> > Here is an example that should definitaly work:
> >
> > Int32 GetText(ref UInt32 pcwcBuffer, IntPtr awcBuffer);
> >
> > And then call it like this:
> > Char[] data = null;
> > IntPtr buff = Marshal.AllocHGlobal(2048); // 1024 Chars;
> > try
> > {
> >         Int32 buffSize = 1024; // 1024 Chars
> >         Int32 ret = MyIFilter.GetText(ref buffSize, buff);
> >         // You might want to do something with 'ret'
> >         data = new Char[buffSize];
> >         Marshal.Copy(buff, data, 0, buffSize);
> > }
> > finally
> > {
> >         Marshal.FreeHGlobal(buff);
> > }
> >
> >
> > I will confess that I only have a few weeks of Marshaling experience in
> > .NET.
> >
> > Hope this helps,
> > --
> > Peter
> >
> > You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
> > subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to