问题描述
以下是一个第三方播放器提供的程序接口,需要在C#的主程序中调用实现对播放器的操作,请问怎样实现?winfrom程序非WEB程序usingSystem;usingSystem.Runtime.InteropServices;namespaceStereoPlayer{[ComVisible(true)][InterfaceType(ComInterfaceType.InterfaceIsIDispatch)][Guid("54150FC5-F6D5-419A-BC0D-E2BE08558934")][TypeLibType(TypeLibTypeFlags.FDispatchable|TypeLibTypeFlags.FDual|TypeLibTypeFlags.FOleAutomation)]publicinterfaceIAutomation{///<summary>///Returnsthenumberofitemsintheplaylist.///</summary>[DispId(0xc9)]voidGetPlaylistItemCount(outintcount);///<summary>///Returnstheindexofthecurrentlyloadedplaylistitem.///</summary>[DispId(0xca)]voidGetPlaylistItem(outintindex);///<summary>///Loadsthespecifiedplaylistitem.///</summary>[DispId(0xcb)]voidSetPlaylistItem([In]intindex);///<summary>///Loadsthenextplaylistitem.///</summary>[DispId(0xcc)]voidNextPlaylistItem();///<summary>///Loadsthepreviousplaylistitem.///</summary>[DispId(0xcd)]voidPreviousPlaylistItem();///<summary>///Opensastereoscopicvideofile.///</summary>[DispId(0xce)]voidOpenFile([In,MarshalAs(UnmanagedType.BStr)]stringfilename);///<summary>///Opensseparateleftandrightvideofilesaswellasanoptionalaudiofile.///</summary>[DispId(0xcf)]voidOpenLeftRightFiles([In,MarshalAs(UnmanagedType.BStr)]stringleftFilename,[In,MarshalAs(UnmanagedType.BStr)]stringrightFilename,[In,MarshalAs(UnmanagedType.BStr)]stringaudioFilename,[In]AudioModeaudioMode);///<summary>///OpensaDVD,specifiedbythepath(withoutVIDEO_TSfolder).///</summary>[DispId(0xd0)]voidOpenDVD([In,MarshalAs(UnmanagedType.BStr)]stringpath);///<summary>///OpensaURL.///</summary>[DispId(0xd1)]voidOpenURL([In,MarshalAs(UnmanagedType.BStr)]stringurl);///<summary>///Opensacapturedevice.Eitherspecifiythefriendlyname(mightnotbeunique)orthedeviceidentified.///</summary>[DispId(210)]voidOpenDevice([In,MarshalAs(UnmanagedType.BStr)]stringdevice);///<summary>///Returnstheplayer'sstate(playing,stopped,...).///</summary>[DispId(0xd3)]voidGetPlaybackState(outPlaybackStatestate);///<summary>///Executesaplaybackcommand(play,stop,...).///</summary>[DispId(0xd4)]voidSetPlaybackState([In]PlaybackStatestate);...................}太长而且都一样补贴全了
解决方案
解决方案二:
参考C#中调用API
解决方案三:
这个是C++的C#不是这么写