当我运行代码,我得到一个错误说口口声声说ActiveX组件不能创建对象:Shell.LocalMachine'
ActiveX组件不能创建对象:Shell.LocalMachine'
Class MachineName
Private internal_ComputerName
Public Function SetMachineName
Set objComputer = CreateObject("Shell.LocalMachine")
internal_ComputerName = objComputer.MachineName
End Function
Public Property Get GetMachineName
GetMachineName = internal_ComputerName
End Property
End Class
Dim objMachine
Set objMachine = New MachineName
objMachine.SetMachineName
是否安装了“Shell.LocalMachine”?用regedit搜索你的注册表 – 2011-08-19 20:57:37
必须承认我之前没有遇到过这个对象。我通常会创建一个[“WScript.Network”](http://msdn.microsoft.com/en-us/library/s6wt333f%28v=vs.85%29.aspx)对象并获取ComputerName属性。如果您正在诊断“Shell.LocalMachine”,我可以告诉您,在我的XP副本中,它由system32 \ shgina.dll – Morbo
提供另请参阅[here](http://www.robvanderwoude.com/vbstech_network_names_computer.php)了解更多信息。 – Morbo