一个VB.NET应用修复Visual Basic 6中的OCX安全问题:{A}{A2的}{A3的}介绍
我开发一个线程的Visual Basic 2010应用程序的验证,如果微软的安全问题(MS08-070漏洞在Visual Basic 6.0中运行时扩展文件(ActiveX控件)可能允许远程执行代码)的计算机上存在。
应用程序检查注册的ActiveX控件和ActiveX控件存在在你的文件系统(未注册)。微软的状态,你需要联系的软件开发人员(即安装这些利用ActiveX控件),并要求更新软件包(将安装更新的ActiveX控件)。你怎么知道哪个软件安装ActiveX控件?为什么不能单个文件进行更新?
我的软件提供了一个简单的方法来检查您的系统和解决,而不必做这一切的研究和主要软件升级的安全问题。
{S0的}此应用程序显示您如何确定的ActiveX(OCX)的文件(32/64位操作系统)电脑通过读取系统注册表,注册。提供了一个实用程序来解决多台计算机上存在一个潜在的安全问题。演示如何使用线程同时读取注册表项和检查文件(通过System.Management)。演示如何允许线程更新一个进度栏和主窗体的DataGridView。演示如何应用样式格式化DataGridView的条目(行的颜色),因为它们被添加,根据输入数据。演示了如何嵌入到你的编译的应用程序文件,并提取所需的文件。此解决方案,解决什么问题?
此Visual Basic(2010)实用程序允许系统管理员,以检查他们的系统和利用VB6的ActiveX控件产生一个修复的作用[注销一个批处理文件,利用OCX文件,重命名,复制更新微软签署} OCX文件{提取出此实用工具},并注册新的OCX文件。没有必要去猜测哪些应用程序安装过时的OCX文件或升级现有的软件。
代码工作如何?
应用程序启动两个线程。第一个线程扫描注册处注册的OCX文件。' Read registry thread
Private Sub Read_Reg()
' Give a name to identify the thread that creates the User Interface
Thread.CurrentThread.Name = "Read_Registry"
Dim x As Integer = 1 'starting count
Dim myAL As New ArrayList() ' holds initial raw registry data
myAL.Clear() 'clear initial raw registry data
Dim strProgID As String = String.Empty
Dim strInprocServer32 As String = String.Empty
Dim strVersion As String = String.Empty
Dim defaultValue As Array
If My.Computer.FileSystem.DirectoryExists("C:\Windows\SysWOW64") Then
'this is a 64 bit OS
'Get all key names
defaultValue = Registry.ClassesRoot.OpenSubKey("Wow6432Node\CLSID").GetSubKeyNames()
Else
'this is a 32 bit OS
'Get all key names
defaultValue = Registry.ClassesRoot.OpenSubKey("CLSID").GetSubKeyNames()
End If
Dim EntryCount As Integer = defaultValue.Length ' number of items to loop thru
代表添加初始化进度条根据注册表计数的主要形式,并推动它同时阅读条目。{C}
第二个线程扫描所有硬盘驱动器上的OCX文件。' Read files thread
Private Sub Check_for_OCX_on_HD()
' Give a name to identify the thread that creates the User Interface
Thread.CurrentThread.Name = "Check_Drives_for_OCX"
'find local drive letters
Dim t2 As New System.Management.SelectQuery(_
"Select DeviceID from Win32_LogicalDisk Where drivetype = '3' ")
Dim r2 As New System.Management.ManagementObjectSearcher(t2)
Dim Drv_Name As System.Management.ManagementObject
Dim Drv_Ltrs As System.Management.ManagementObjectCollection = r2.Get()
Dim Drv_Ltrs_Count As Integer = Drv_Ltrs.Count
Dim DrvLtrArray As New ArrayList
For Each Drv_Name In Drv_Ltrs
DrvLtrArray.Add("Drive='" & _
Drv_Name("DeviceID").ToString & "'").ToString()
Next Drv_Name
' Display querying files
Count_File_Entry("(Querying Files)")
'create multiple drive letter str for next WMI query (if multiple drive letters)
Dim myArr4 As String() = CType(DrvLtrArray.ToArray(GetType(String)), String())
Dim DrvSearch As String = String.Join(" Or ", myArr4)
Dim q As New System.Management.SelectQuery("Select * from " & _
"CIM_DataFile Where Extension = 'ocx' and (" & DrvSearch & ")")
Dim s As New System.Management.ManagementObjectSearcher(q)
Dim OCX_Lst As System.Management.ManagementObjectCollection = s.Get()
Dim OCX_Count As Integer = OCX_Lst.Count
' display file count
Count_File_Entry("(Processing " & OCX_Count & " Files)")
代表添加到允许的线程将行添加到主要形式DataGridViews的。{体C3}
本次修订的变化2 2010年11月
Read_Reg的子程序修改旧线(316 - 341)。
我现在检查一个注册表项和测试,如果一个空项目,然后再尝试读取注册表值存在。许多空的例外被抛出在旧的代码。现在我也看完后关闭注册表项。
旧代码:{的C4}
新的代码:{C5的}
兴趣点
我学到了很多东西,而开发这个应用程序,并随时欢迎评论,以提高我的代码。这是我的第一个线程的应用程序。也是我第一次应用程序,嵌入式资源(新的OCX文件),并提取他们的要求。
应用样式格式的DataGridView行(根据颜色的行不是一个VB6的OCX,可开发的OCX,当前的OCX)的首次使用。
我用这个实用程序来检查,至少有80台电脑,最有几VB6的OCX文件,需要更新。在这篇文章中看到如何使用这个软件的顶部阅读PDF文档。编译工具是只有8兆,即使它有26 VB6的OCX的文件作为资源嵌入。不包括由于张贴大小限制的源代码编译的工具。历史2011年10月23日发布的第1版。2011年11月2日发布的第2版。