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下的情況。
|