1. 程式人生 > >在Win8.1 X64下安裝VB6及後續補丁的正確方法

在Win8.1 X64下安裝VB6及後續補丁的正確方法

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