2

我正在尝试将此VBScript代码转换为Python (Win32) 代码,但没有运气!

Dim objMain, objSysInf, stMsg

Set objMain = CreateObject("nnetcom.oMain")

Call objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")

Set objSysInf = CreateObject("nnetcom.oSystemInfo")

Call objSysInf.GetSystemInfos

stMsg = objSysInf.cOsName & " " & objSysInf.cOsType & vbCrLf & _
        objSysInf.cOsCpu & vbCrLf & objSysInf.cOsMem & vbCrLf & _
        objSysInf.cOsGpu

MsgBox stMsg, vbInformation, "System Information"

Set objSysInf = Nothing
Set objMain = Nothing

我正在运行安装了Python 2.7.3Python for Windows Extensions的 Windows 7 32 位。此外,我通过从... “Lib\site-packages\win32com\client\”执行“makepy.pyc”添加了 COM 对象,但没有运气,总是收到一些错误消息...

这是我的 Python 代码:

import pythoncom
import win32com.client

objMain = win32com.client.Dispach("nnetcom.oMain")

ret = objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx")

objSysInf = win32com.client.Dispach("nnetcom.oSystemInfo")

objSysInf.GetSystemInfos()

stMsg = objSysInf.cOsName

print(stMsg)

有没有人可以帮助我进行这次谈话?

4

1 回答 1

4

Dispach应该是Dispatch

于 2012-04-22T13:32:19.940 回答