Visual Basic 6.0 的强大生命力使人舍不得放弃。微软在Win8一开始发行的时候,宣布过不再支持VB6,这招致了大量VB6的粉丝的不满。但是到了后来,又看到有人说可以在Win8上使用VB6了,这样对我来说,这当然是好事。今天因为调试一个软件,需要用到VB6对一些算法进行验证,于是就在Win8.1 64位企业版的4月8日更新的环境上,安装了VB6。 我的安装源选择的是VB6中文企业版,一开始进行的并不顺利,在运行Setup程序时,使用管理员身份,并且选定兼容XP SP3的方式。在Setup程序启动后,安装内容全选。这个在前面的安装复制文件过程都比较顺利,但是到了后面更新系统时,就会死机在那里不动了。 上网查阅其他人的安装过程,发现在开始选择时,不能选择“数据工具”的项目,否则就会有这个问题。按照这个方法,重新进行安装,一切顺利完成。后重启系统,安装MSDN以及SP6CN的更新,都算顺利完成。 此时启动VB6的界面,进入工程菜单,选择部件,使用早期的OCX控件,选择要使用的控件,如MScomm串口通讯控件,这时就会发现出现注册表错误。经过查询,发现是 Win8 下的注册表权限问题导致。需要对这些控件进行重新注册,才能正常使用。例如MSCOMM控件,对应的OCX文件为 C:\Windows\sysWOW64\mscomm32.ocx。因此需要以管理员身份打开一个命令行窗口,然后使用命令对这个控件进行处理如下: 先将现在已注册的OCX控件从系统中反注册,使用以下命名: c:\Windows\sysWOW64\regsvr32.exe /u mscomm32.ocx 命令成功后,出现以下提示 ![]() 然后再次对该控件进行注册,命令如下: c:\Windows\sysWOW64\regsvr32.exe mscomm32.ocx 命令成功后,出现以下对话框 ![]() 此时再回到VB6的工程,部件列表中,选定该控件,确定,即可添加该控件,正常使用。如下图: ![]() 鉴于安全的问题,在2009年以后,VB6的多个控件存在问题,被微软禁止在VBA环境下使用。因此直接安装完成的VB6 SP6控件,在 Excel 等VBA环境中使用时,又会出现无法操作的现象。2012年4月9日,微软发布了VB6SP6的累计安全更新包KB2708437,对前期使用的多个控件进行更新。更新后的控件能够正常的在VBA环境下使用。但是,又可能出现需要在Win8下对原有控件反注册后再次用新安装的控件进行注册的问题。 为了便于操作,把这些受影响的控件(包括OCX 和部分DLL),以及常用的 TeeChart V5.0 控件,VB6IDEMouseWheelAddin控件全部复制到一个VB6OCX目录下,并且把KB2708437的更新后的OCX替换原来VB6SP6直接安装的OCX后,制作了一个复制,反注册,再重新注册的批处理文件。把这些内容打包后,用于正常安装VB6的补充。 这个批处理的文件内容如下: @echo off echo This is a patch to VB6 installed in Win8 X64 system. Which echo using VB6 SP6 Chinese package and with security patch KB2708437 echo fixed the issue used in VBA inside Excel. echo echo You must run this batch file as ADMINISTRATOR. echo echo echo copy those DLLs and OCXs to system32 or SysWOW64, and then echo register them into system, your VB6 can run under Win8. copy .\*.dll %windir%\system32\ copy .\*.ocx %windir%\system32\ regsvr32 /s /u comcat.dll regsvr32 /s /u COMCT232.OCX regsvr32 /s /u comct332.ocx regsvr32 /s /u comctl32.ocx regsvr32 /s /u comdlg32.ocx regsvr32 /s /u dbadapt.dll regsvr32 /s /u dbgrid32.ocx regsvr32 /s /u dblist32.ocx regsvr32 /s /u Flash.ocx regsvr32 /s /u FM20.DLL regsvr32 /s /u grid32.ocx regsvr32 /s /u MCI32.OCX regsvr32 /s /u MSADODC.OCX regsvr32 /s /u MSBCODE9.OCX regsvr32 /s /u MSBind.dll regsvr32 /s /u MSCHRT20.OCX regsvr32 /s /u mscomct2.ocx regsvr32 /s /u MSCOMCTL.OCX regsvr32 /s /u MSCOMM32.OCX regsvr32 /s /u MSDATGRD.OCX regsvr32 /s /u MSDATLST.OCX regsvr32 /s /u MSDATREP.OCX regsvr32 /s /u MSDbRpt.dll regsvr32 /s /u MSDbRptr.dll regsvr32 /s /u Msflxgrd.ocx regsvr32 /s /u MSHFLXGD.OCX regsvr32 /s /u MSINET.OCX regsvr32 /s /u msmapi32.ocx regsvr32 /s /u msmask32.ocx regsvr32 /s /u MSRDC20.OCX regsvr32 /s /u msrdo20.dll regsvr32 /s /u msscript.ocx regsvr32 /s /u msstdfmt.dll regsvr32 /s /u msstkprp.dll regsvr32 /s /u mstscax.dll regsvr32 /s /u msvidctl.dll regsvr32 /s /u MSWINSCK.OCX regsvr32 /s /u PICCLP32.OCX regsvr32 /s /u richtx32.ocx regsvr32 /s /u shell32.dll regsvr32 /s /u sysinfo.ocx regsvr32 /s /u tabctl32.ocx regsvr32 /s /u TeeChart.ocx regsvr32 /s /u VB6IDEMouseWheelAddin.dll regsvr32 /s /u wbclsdsr.Ocx regsvr32 /s /u wiaaut.dll regsvr32 /s /u ZoomControl.ocx regsvr32 /s comcat.dll regsvr32 /s COMCT232.OCX regsvr32 /s comct332.ocx regsvr32 /s comctl32.ocx regsvr32 /s comdlg32.ocx regsvr32 /s dbadapt.dll regsvr32 /s dbgrid32.ocx regsvr32 /s dblist32.ocx regsvr32 /s Flash.ocx regsvr32 /s FM20.DLL regsvr32 /s grid32.ocx regsvr32 /s MCI32.OCX regsvr32 /s MSADODC.OCX regsvr32 /s MSBCODE9.OCX regsvr32 /s MSBind.dll regsvr32 /s MSCHRT20.OCX regsvr32 /s mscomct2.ocx regsvr32 /s MSCOMCTL.OCX regsvr32 /s MSCOMM32.OCX regsvr32 /s MSDATGRD.OCX regsvr32 /s MSDATLST.OCX regsvr32 /s MSDATREP.OCX regsvr32 /s MSDbRpt.dll regsvr32 /s MSDbRptr.dll regsvr32 /s Msflxgrd.ocx regsvr32 /s MSHFLXGD.OCX regsvr32 /s MSINET.OCX regsvr32 /s msmapi32.ocx regsvr32 /s msmask32.ocx regsvr32 /s MSRDC20.OCX regsvr32 /s msrdo20.dll regsvr32 /s msscript.ocx regsvr32 /s msstdfmt.dll regsvr32 /s msstkprp.dll regsvr32 /s mstscax.dll regsvr32 /s msvidctl.dll regsvr32 /s MSWINSCK.OCX regsvr32 /s PICCLP32.OCX regsvr32 /s richtx32.ocx regsvr32 /s shell32.dll regsvr32 /s sysinfo.ocx regsvr32 /s tabctl32.ocx regsvr32 /s TeeChart.ocx regsvr32 /s VB6IDEMouseWheelAddin.dll regsvr32 /s wbclsdsr.Ocx regsvr32 /s wiaaut.dll regsvr32 /s ZoomControl.ocx echo Done. echo Press any key to continue... echo on 附:文件列表: 2014/03/10 周一 11:11 466,680 BsSDK.dll 2009/07/14 周二 09:15 7,168 comcat.dll 2010/02/16 周二 15:22 170,080 ComCt232.ocx 2010/02/16 周二 15:22 415,552 ComCt332.ocx 2012/05/02 周三 12:17 617,816 comctl32.Ocx 2010/02/16 周二 15:22 155,984 ComDlg32.OCX 2010/02/16 周二 15:22 57,168 dbadapt.dll 2010/02/16 周二 15:22 567,104 dbgrid32.ocx 2010/02/16 周二 15:22 222,528 dblist32.Ocx 2014/04/01 周二 05:23 12,351,992 Flash.ocx 2014/01/23 周四 15:54 1,239,208 FM20.DLL 2009/03/31 周二 10:48 89,600 grid32.ocx 2010/02/16 周二 15:22 215,880 mci32.Ocx 2010/02/16 周二 15:22 134,976 MSAdoDc.ocx 2010/10/20 周三 16:36 128,880 MSBCODE9.OCX 2010/02/16 周二 15:22 84,808 MSBind.dll 2010/02/16 周二 15:22 1,029,968 MSChrt20.ocx 2010/02/16 周二 15:22 659,264 mscomct2.ocx 2012/05/02 周三 12:17 1,070,152 mscomctl.OCX 2010/02/16 周二 15:22 119,616 MSComm32.Ocx 2010/02/16 周二 15:22 69,440 MSCsfDbg.dll 2010/02/16 周二 15:22 278,352 MSDatGrd.ocx 2010/02/16 周二 15:22 252,240 MSDatLst.Ocx 2010/02/16 周二 15:22 206,160 MSDatRep.Ocx 2010/02/16 周二 15:22 340,800 MSDbRpt.dll 2010/02/16 周二 15:22 328,512 MSDbRptr.dll 2010/02/16 周二 15:22 258,880 MSFlxGrd.ocx 2010/02/16 周二 15:22 443,488 MShflxgd.ocx 2010/02/16 周二 15:22 136,008 MSINET.Ocx 2010/02/16 周二 15:22 151,376 msmapi32.Ocx 2010/02/16 周二 15:22 178,512 msmask32.ocx 2010/02/16 周二 15:22 190,800 msrdc20.Ocx 2010/02/16 周二 15:22 449,872 msrdo20.dll 2009/07/14 周二 09:14 95,232 msscript.ocx 2010/02/16 周二 15:22 129,872 msstdfmt.dll 2010/02/16 周二 15:22 107,840 msstkprp.dll 2010/12/22 周三 19:29 2,690,560 mstscax.dll 2008/04/14 周一 03:13 1,417,728 msvidctl.dll 2010/02/16 周二 15:22 126,800 MSWINSCK.ocx 2010/02/16 周二 15:22 100,160 PicClp32.Ocx 2010/02/16 周二 15:22 218,432 richtx32.Ocx 2012/06/08 周五 22:25 8,320,512 shell32.dll 2010/02/16 周二 15:22 80,208 sysinfo.Ocx 2010/02/16 周二 15:22 221,504 TabCtl32.Ocx 2014/04/20 周日 18:07 383,488 teechart.oca 2011/04/06 周三 18:07 2,602,496 TeeChart.ocx 2014/04/20 周日 19:40 10,312,704 VB60SP6-KB2708437-x86-CHS.msi 2011/04/16 周六 11:03 36,864 VB6IDEMouseWheelAddin.dll 2014/04/20 周日 23:18 3,083 VB6Win8Patch.bat 2011/04/16 周六 11:03 227 VBA Mouse Wheel Fix.reg 2010/02/16 周二 15:22 334,672 wbclsdsr.Ocx 2009/07/14 周二 09:16 544,256 wiaaut.dll 2001/09/18 周二 16:28 28,672 ZoomControl.ocx 53 个文件 50,844,174 字节 2 个目录 23,614,660,608 可用字节 按照这个做法,可以减少很多出错并查找文件的过程,方便VB6在 Win8 下使用。 没有验证在 32位 Win8.1下的情况。 |