Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- From: Helen <Helen@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 08:48:06 -0800
Thanks Jeremy! Now I know.
Helen
"Jeremy Noring" wrote:
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
- References:
- RE: Error signature when calling GetScriptCount of IWMHeaderInfo3
- From: Helen
- Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- From: Jeremy Noring
- RE: Error signature when calling GetScriptCount of IWMHeaderInfo3
- Prev by Date: RE: "Attempted to read or write protected memory" with GetScriptCo
- Next by Date: Re: Corrupted heap error in preparetoencode
- Previous by thread: Re: Error signature when calling GetScriptCount of IWMHeaderInfo3
- Next by thread: how to know when IWMReaderCallback::OnSample() is called no more (end of data)
- Index(es):
Relevant Pages
|