C# 使用 WebBrowser 控件访问 Flash COM 对象
我有一个 HTML 页面,其中包含一个 flash 文件和一些返回 flash 文件对象的 JavaScript 函数。
到目前为止,我可以从 C# 调用 JavaScript 函数并让它返回一个对象,但我想将其转换为 AxShockwaveFlash 并直接从 C# 访问 COM 对象。
我已经看到使用嵌入在 HTML 页面中的 Windows Media Player 完成此操作,但它似乎不适用于 Flash。
<代码> <脚本类型=“文本/JavaScript”>函数 GetWMP() { 返回(测试);
object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="857" height="480" id="testing">
<参数名称=“质量”值=“高”/>
<参数名称=“bgcolor”值=“#ffffff”/>
<参数名称=“allowFullScreen”值=“true”/>
<代码>
下面是我的 C# 代码,它返回该对象。
<代码> object o = webBrowser1.Document.InvokeScript("ReturnFlash");
AxShockwaveFlashObjects.AxShockwaveFlash flash = (AxShockwaveFlashObjects.AxShockwaveFlash)o;
当我尝试将对象转换为 AxShockwaveFlash 时失败,但是我已经看到它可以将对象投射到 WindowsMediaPlayer。
我试图根据错误消息查找 AxShockwaveFlash 是否支持 QueryInterface 调用,但 Google 没有返回任何有价值的内容。
谢谢
I have a HTML page that contains a flash file and some a JavaScript function that returns the object of the flash file.
So far I can call the JavaScript function from C# and have it return an Object, but I want to cast it as AxShockwaveFlash and access the COM Object directly from C#.
I have seen this done with Windows Media Player imbedded in the a HTML page, but it doesn't seem to work with flash.
<script type="text/JavaScript"> function GetWMP() { return(testing); } <script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="857" height="480" id="testing">
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
</object>
Below is my C# code which returns the object.
object o = webBrowser1.Document.InvokeScript("ReturnFlash");
AxShockwaveFlashObjects.AxShockwaveFlash flash = (AxShockwaveFlashObjects.AxShockwaveFlash)o;
When I try to cast the Object to AxShockwaveFlash it fails, but I have seen it work casting the object to WindowsMediaPlayer.
I tried to find if AxShockwaveFlash supports QueryInterface calls, as per the error message but Google returned nothing of value.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AxShockwaveFlash 是一个自动生成的 Windows 窗体控件,由 aximp.exe 创建。所以你可以把它写在表格上。你得到的那个对象不是那个控件。您只能转换到互操作包装器公开的接口,该接口应该是 ShockwaveFlashObjects.ShockwaveFlash。
AxShockwaveFlash is an auto-generated Windows Forms control, created by aximp.exe. So you can put it on a form. That object you got is not that control. You can only cast to the interface exposed by the interop wrapper, which should be ShockwaveFlashObjects.ShockwaveFlash.