“使用"不存在的项目 [英] "Using" a non-existent item

查看:66
本文介绍了“使用"不存在的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有可用于进行此测试的系统,如果我创建一个使用"wmp.dll"的应用程序,但系统上没有wmp.dll,会发生什么情况? (就像Windows的"N"版本一样)?

我的应用程序使用嵌入式Media Player进行视频预览.我可以轻松地发现错误,或预先检测" WMP的不存在,然后将流重定向到使用VideoLan播放器的表单吗?

错误会在哪里弹出?只是在调用预览表单时,还是由于对WMPLib和AxWMPLib的引用,它将在应用程序启动时立即检测到它吗?

(这可能并不重要,但这是在针对Win7的C#中)

以后...
将两种不同的Preview形式放到单独的DLL中(视情况而定)会是一个更好的主意吗?

而且,如果是这样,如何%^ $#%!我能使它正常工作吗?我尝试了一下,然后弹出了一个表单",但它与我设计的表单没有任何相似之处,完全空白.

Not having a system readily available to test this on, what happens if I create an app that uses "wmp.dll", but wmp.dll is not on the system? (Like the "N" versions of Windows)?

My app uses an embedded Media Player for video preview. Can easily I catch the error, or "pre-detect" the non-existence of WMP, and redirect the flow to a form which uses the VideoLan player instead?

Where would the error pop up? Just when the preview form is called, or will it detect it right from the start of the app because of the references to WMPLib and AxWMPLib?

(Not that it probably matters, but this is in C# targetting Win7)

Later...
Would putting the two varieties of Preview forms in separate DLLs, called as appropriate, be a better idea?

And, if so, how the %^$#%! do I get it to work? I tried it and a "form" pops up, but it bears no resemblance to anything to the form I designed, being completely blank.

推荐答案

#%!我能使它正常工作吗?我尝试了一下,然后弹出了一个表单",但是它与我设计的表单没有任何相似之处,完全空白.
#%! do I get it to work? I tried it and a "form" pops up, but it bears no resemblance to anything to the form I designed, being completely blank.


取决于如何访问DLL,您可能会得到启动时出错,或者在首次尝试访问它时可能会出错.在您的情况下,您似乎正在通过C#使用COM互操作,因此尽管您显然不会在UI中看到ActiveX控件,但您很可能本身不会收到错误.解决此问题的一种方法是尝试检测启动时是否存在wmp(应通过检查注册表来实现),如果不存在,则显示错误消息并退出.

提示:尝试打开并浏览此键
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer
Depending on how a DLL is accessed, you may get an error on startup or you may get an error on the first attempt to access it. In your case, you seem to be using COM interop via C#, so you''ll most likely not get an error per se, although you''ll obviously not see the ActiveX control in your UI. One way to work around this is to try and detect if wmp is present on startup (should be possible by examining the registry) and if it''s not present, then show an error message and quit.

Hint: try opening and going through this key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer


这篇关于“使用"不存在的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆