如何在Python中使用win32 API?最好和最简单的方法是什么?你能提供一些例子吗?
3 回答

胡子哥哥
TA贡献1825条经验 获得超6个赞
如@chaos所述,PyWin32可能是最受欢迎的选择。另一种选择是ctypes,它是Python标准库的一部分。例如,print ctypes.windll.kernel32.GetModuleHandleA(None)将显示当前模块(EXE或DLL)的模块句柄。这里是使用ctypes获取win32 API的更广泛的示例。

holdtom
TA贡献1805条经验 获得超10个赞
可以在win32 Python中使用的重要功能是消息框,这是OK或Cancel的经典示例。
result = win32api.MessageBox(None,"Do you want to open a file?", "title",1)
if result == 1:
print 'Ok'
elif result == 2:
print 'cancel'
集合:
win32api.MessageBox(0,"msgbox", "title")
win32api.MessageBox(0,"ok cancel?", "title",1)
win32api.MessageBox(0,"abort retry ignore?", "title",2)
win32api.MessageBox(0,"yes no cancel?", "title",3)
添加回答
举报
0/150
提交
取消