當我運行代碼,我得到一個錯誤說口口聲聲說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