- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
这个问题是我的 previous question 的延续.
我正在尝试获取 Network Statistics
对于我的 Windows 7
系统使用PyWin32
.
我遵循的步骤:
1) Run
COM MakePy utility
and than selectnetwork list manager 1.0
under type library.
type library2) Above process generated this python file.
接下来我创建了类 NetworkListManager(CoClassBaseClass)
的对象使用
import win32com.client as wc
obj = wc.Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")
现在我正在尝试访问上面创建的对象提供的方法 obj
.
help(obj)
给了我
GetNetwork(self, gdNetworkId= <PyOleEmpty object>
)
Get a network given a Network ID.
已连接
Returns whether connected to internet or not
//Other methods removed
所以,现在当我使用
>>> obj.IsConnected
True
它工作正常。
现在我面临的问题是如何使用GetNetowrk
方法因为当我尝试使用它时
>>> obj.GetNetwork()
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ret = self._oleobj_.InvokeTypes(2, LCID, 1, (9, 0), ((36, 1),),gdNetworkId
com_error: (-2147024809, 'The parameter is incorrect.', None, None)
我也试过创建 PyOleEmpty object
通过使用 pythoncom.Empty
并将其作为参数传递但没有运气。
我明白了GetNetwork
需要 NetworkID
作为参数,但方法 GetNetworkId
在 INetwork 中定义类。
所以我的问题是如何使用在使用 MakePy utility
创建的 python 文件中定义的类这不是CoClass
.
最佳答案
看起来获取网络对象的方法是使用 GetNetworks 枚举它们:
networks=obj.GetNetworks(win32com.client.constants.NLM_ENUM_NETWORK_CONNECTED)
for network in networks:
print (network.GetName(), network.GetDescription())
使用网络 ID 会有问题。它们被定义为原始结构,因此需要使用 Records 传递它们。 Pywin32对IRecordInfo接口(interface)的支持还是有些薄弱。
关于python - PyWin32 使用 MakePy 实用程序和 win32com 获取网络统计信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9982235/
我正在尝试检查 PyWin 在 Excel 的 COM 接口(interface)中返回的数据是否属于“时间”类型。 这是不起作用的代码: from win32com.client import Di
我在 Win32 上使用 Python 与 OneNote 的 COM 互操作进行交互。 下面是提取笔记本层次结构的最基本代码: import win32com.client onObj = win3
我是一名优秀的程序员,十分优秀!