它一直说 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
When I run the code, I get an error saying
ActiveX component can't create object: '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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢你。当我尝试运行简单的 vbscript 代码时,在 Windows 7 64 位计算机上使用此
Shell.Localmachine
时,我遇到了同样的问题。我必须默认为WScript.Network
:thanks for this. I am having the same problems when using this
Shell.Localmachine
on my windows 7 64 bit machine when i try to run a simple vbscript code. I had to default toWScript.Network
instead:Morbo 说:“必须承认我以前没有遇到过该对象。我通常会创建一个“WScript.Network”对象并获取 ComputerName 属性。如果您正在诊断“Shell.LocalMachine”,我可以在我的网站上告诉您这一点。 XP 的副本由 system32\shgina.dll 提供”
Morbo said "Must admit I hadn't come across that object before. I'd normally create a "WScript.Network" object and get the ComputerName property. If you're diagnosing "Shell.LocalMachine" I can tell you that on my copy of XP it is provided by system32\shgina.dll"