Re: Error signature when calling GetScriptCount of IWMHeaderInfo3



On Feb 11, 2:04 pm, Helen <He...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
It's posted before I could finish. Here is the code snippet:

public class MyProgram
{
IWMMetadataEditor wmEditor = null;
IWMHeaderInfo3 headerInfo = null;
WMFWrapper.WMCreateEditor(out wmEditor);
wmEditor.Open("some.wma");
headerInfo = (IWMHeaderInfo3)wmEditor;
ushort count;
headerInfo.GetScriptCount(out count);

}

The wapper is from the SDK, here is the part I use:
public class WMFWrapper
{
[DllImport("WMVCore.dll", EntryPoint = "WMCreateEditor",
SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern uint WMCreateEditor(
[Out, MarshalAs(UnmanagedType.Interface)] out IWMMetadataEditor
ppMetadataEditor);
}

[ComImport,
Guid("96406BD9-2B2B-11d3-B36B-00C04F6108FF"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWMMetadataEditor
{
uint Open([In, MarshalAs(UnmanagedType.LPWStr)] string pwszFilename);
uint Close();
uint Flush();

}

[ComImport,
Guid("15CC68E3-27CC-4ecd-B222-3F5D02D80BD5"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWMHeaderInfo3
{
uint GetScriptCount(
[Out] out ushort pcScripts);
}

This is definitely your problem--when declaring COM interfaces
in .NET, you cannot simply pick and choose what methods you want. All
methods need to be declared, and furthermore, they need to be in order
(notice WMFSDKFunction.cs declares _all_ of IWMHeaderInfo3, and the
order in which methods are declared matches the order found in the
native interface declaration).

COM Interfaces cannot include any interfaces in their base interface
list, and they must declare the interface member functions in the
order that the methods appear in the COM interface. COM interfaces
declared in C# must include declarations for all members of their base
interfaces with the exception of members of IUnknown and IDispatch --
the .NET Framework automatically adds these. COM interfaces which
derive from IDispatch must be marked with the InterfaceType attribute.

See here for more info:

http://msdn2.microsoft.com/en-us/library/aa645736(VS.71).aspx
.



Relevant Pages

  • Re: Riddle Me This
    ... All you should do is declare the IWMHeaderInfo3 and the IWMMetadataEditor COM interfaces and declare the WMCreateEditor function exported by the WMVCore.dll. ... Here the PInvoke declaration and part of the COM interface definitions to get you started. ... public static extern uint WMCreateEditor( ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
    ... public static extern uint WMCreateEditor( ... public interface IWMMetadataEditor ... public interface IWMHeaderInfo3 ... This is definitely your problem--when declaring COM interfaces ...
    (microsoft.public.windowsmedia.sdk)
  • Re: avoiding writing an interface blocks
    ... arguments wouldn't require an interface on their own. ... thinking that is part of declaring the type. ... an implicit interface is - not an explicit one. ...
    (comp.lang.fortran)
  • Re: Questions of Designs
    ... This is crude way of declaring complete abstract behavior using language specific syntax. ... What's so different about the C++ ABC above and this Java interface: ...
    (comp.object)
  • Re: Asking again: Implementing interface, returning subclass
    ... example is the oppisate of this where it lets the class act like ... But I want to turn the i/f into a class that implements it. ... You need to have two properties - one implementing the interface ... and declaring it to return the concrete type. ...
    (microsoft.public.dotnet.languages.csharp)