我的目标是在ctypes和user32.dll(SystemParametersInfo)的帮助下在python中获取可用的工作区。好吧,我第二次使用ctypes并且不太了解它。解释我做错了会很棒。感谢。
SELECT * FROM MyTable WHERE instr("afm", myChar)>0;
答案 0 :(得分:2)
您有一些错误:
SystemParametersInfoW
(尽管它可能对这个特定函数有任何作用)。RECT
结构。函数调用将其修改到位。结合这些更改,代码对我有用:
import ctypes
SPI_GETWORKAREA = 48
SPI = ctypes.windll.user32.SystemParametersInfoW
class RECT(ctypes.Structure):
_fields_ = [
('left', ctypes.c_long),
('top', ctypes.c_long),
('right', ctypes.c_long),
('bottom', ctypes.c_long)
]
SPI.restype = ctypes.c_bool
SPI.argtypes = [
ctypes.c_uint,
ctypes.c_uint,
ctypes.POINTER(RECT),
ctypes.c_uint
]
rect = RECT()
result = SPI(
SPI_GETWORKAREA,
0,
ctypes.byref(rect),
0
)
if result:
print('it worked!')
print(rect.left)
print(rect.top)
print(rect.right)
print(rect.bottom)