views:

1572

answers:

5

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?

+1  A: 

It's possible you're running into an issue with Data Execution Protection (DEP). Test it out by disabling DEP:

bcdedit.exe /set {current} nx AlwaysOff

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.

C-Pound Guru
+1 Yep sounds like classic DEP, definitely the first port of call.
AnthonyWJones
+1  A: 

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

AnthonyWJones
+2  A: 

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.

MarkJ
+6  A: 

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.

Joel Spolsky
+1  A: 

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)