在 VB6 应用程序中使用 ImageList 会导致 Windows 7.0 64 位崩溃
我有一个旧的 VB6 应用程序,它使用 COMCTL32.OCX(“Microsoft Windows Common Controls 5.0 (SP2)”)中的 ImageList 控件来提供 TreeView 和 ListView 的图标。
该应用程序甚至无法在 Windows 7.0 64 位上启动。 当它尝试加载包含 ImageList 的表单时,它就会崩溃(好吧,实际上,应用程序眨眼退出,不留痕迹地退出)。
从表单中删除 ImageList 可以解决该问题。
有任何想法吗?
I have an old VB6 application that uses an ImageList control from COMCTL32.OCX ("Microsoft Windows Common Controls 5.0 (SP2)") to provide icons for TreeViews and ListViews.
The app won't even launch on Windows 7.0 64 bit. The minute it tries to load the form that has the ImageList on it, it crashes (well, actually, the app winks out, exiting without a trace).
Removing the ImageList from the form solves the problem.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我通过将 VB5 附带的 COMCTL32.OCX 的所有实例替换为 VB6 附带的 MSCOMCTL.OCX 解决了这个问题。
Microsoft 知识库文章 190952 提供了执行此操作的说明。 这几乎只是一个全局搜索和替换操作。
I resolved this problem by replacing all instances of COMCTL32.OCX, which came with VB5, with MSCOMCTL.OCX, which came with VB6.
Microsoft KB article 190952 has instructions for doing this. It was pretty much just a global-search-and-replace operation.
向 Microsoft 报告错误。 VB6 运行时在 64 位 Windows 7 上仍然受支持。 COMCTL32 .ocx 未随 Windows 7 一起安装,但明确列出 Windows 7 支持。
Report a bug to Microsoft. The VB6 runtime is still supported on 64-bit Windows 7. COMCTL32.ocx isn't installed with Windows 7, but it is explicitly listed as supported on Windows 7.
你的解决方案没问题。
但无论如何,COMCTL32.OCX 在 Win64(Vista 或 7)上应该可以正常工作。
只是一点建议:
如果使用 MSCOMCTL.OCX,您将无法将 XP/Vista/7 样式应用于列表视图或树视图,并且您的应用程序可能看起来很陌生。 清单不会对 MSCOMCTL.OCX 控件产生任何影响。
解决方法是对 MSCOMCTL.OCX 控件进行子类化,并且由于它们仍然包含 COMCTL32.DLL 标头,因此您可以操纵它的绘制方式。
(我本来想发表评论,但我还是不能)
Your solution is OK.
But COMCTL32.OCX should work fine on Win64 anyway (Vista or 7).
Just a little advice:
If using MSCOMCTL.OCX you won't be able to apply to your listview or treeview the XP/Vista/7 style and your app might look alien. Manifest won't have any effect on MSCOMCTL.OCX controls.
A workaround would be to subclass the MSCOMCTL.OCX controls, and since they still contain a COMCTL32.DLL header you could manipulate how it paints.
(I would've posted as a comment, but I still can't)
您可能遇到数据执行保护 (DEP) 问题。 通过禁用 DEP 进行测试:
在命令行中输入上述内容后重新启动。 请记住将其重新打开,因为这相当于脱下裤子运行 Windows。
编辑:上面的命令适用于 Vista。 我还没有在 Windows 7 上尝试过。
It's possible you're running into an issue with Data Execution Protection (DEP). Test it out by disabling DEP:
Reboot after entering the above in a command line. Remember to turn it back on as it's the equivalent of running Windows with your pants down.
Edit: The command above works on Vista. I haven't tried it on Windows 7.
一个不太剧烈的 DEP 调整是进入计算机性能对话框(系统属性的高级选项卡)并将应用程序 exe 添加到 DEP 选项卡上的例外列表中。
顺便说一句,您确定这不属于 serverfault.com 吗? :P
A less drastic DEP tweak is go into the computers performance dialog (advanced tab of system properties) and add the apps exe to the list of exceptions on the DEP tab.
BTW, are you sure this doesn't belong on serverfault.com. :P