0
我想在我的窗口中列出我的輸入設備(如麥克風等)。在python中使用winmm.dll來獲得輸入設備
的代碼是在這裏:
from ctypes import *
import sys
#printf = libc.printf
winmm = windll.LoadLibrary("winmm.dll")
widn = winmm.waveInGetDevCapsA #wave in device num
widn.restype = c_uint
waveNum = winmm.waveInGetNumDevs
class LPWAVEINCAPS(Structure):
_fields_ = [
("wMid",c_ushort),
("wPid",c_ushort),
("vDriverVersion",c_uint),
("szPname",c_wchar_p),
("dwFormats",c_uint),
("wChannels",c_ushort),
("wReserved1",c_ushort),
]
widn.argtypes = [
c_uint,
POINTER(LPWAVEINCAPS),
c_uint
]
count_devs = waveNum()
print(count_devs)
structLP = LPWAVEINCAPS()
for i in range(count_devs):
str = widn(c_uint(i),byref(structLP),c_uint(sys.getsizeof(structLP)))
print(structLP.szPname)
輸出是段故障,當我刪除byref
它給了我None
作爲輸出。
請幫我謝謝你了:)