VB6如何判断电脑上是否安装了.net framework

2025-01-06 06:41:04
推荐回答(2个)
回答1:

VB6本身不是.NET架构的,要检测是否安装.NET框架,需得VB.NET,代码如下:
'WMI检查本机是否安装了.NET Framework
Public Function IsMSFrameworkInstalled() As Boolean
On Error Resume Next
Dim objWMIService
Dim colItems
Dim objItem
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Product")
For Each objItem In colItems
If InStr(objItem.Name, "Microsoft .NET Framework") > 0 Then
IsMSFrameworkInstalled = True
End If
Next
End Function

'调用:
MsgBox IsMSFrameworkInstalled()

回答2:

读注册表