Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- From: Jeremy Noring <kidjan@xxxxxxxxx>
- Date: Mon, 11 Feb 2008 20:29:20 -0800 (PST)
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
.
- Follow-Ups:
- References:
- Prev by Date: Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- Next by Date: how to know when IWMReaderCallback::OnSample() is called no more (end of data)
- Previous by thread: Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- Next by thread: Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- Index(es):
Relevant Pages
|