使用python ctypes获取系统硬件.uuid有错误消息

2024-09-30 14:37:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用python ctypes获取系统硬件.uuid. 在i386机器上执行的python程序不会失败。 但是在x64机器上执行的同一个程序会产生错误。在

这是我的python类:

self._hal = ctypes.cdll.LoadLibrary(find_library('hal'))
self._ctx = self._hal.libhal_ctx_new()
self._dbus_error = dbus_error()
self._hal.dbus_error_init(ctypes.byref(self._dbus_error))
self._conn = self._hal.dbus_bus_get(ctypes.c_int(1),ctypes.byref(self._dbus_error))
self._hal.libhal_ctx_set_dbus_connection(self._ctx, self._conn)
udi = ctypes.c_char_p("/org/freedesktop/Hal/devices/computer")
key = ctypes.c_char_p("system.hardware.uuid")
self._hal.libhal_device_get_property_string.restype = ctypes.c_char_p
self._uuid_ = self._hal.libhal_device_get_property_string(self._ctx, udi, key,   self._dbus_error)
return self._uuid_

下面是错误消息:

[tmp]$/测试-uid.py文件在

^{pr2}$

Tags: self程序机器getuuid错误errorconn