Open Starxyz opened 5 years ago
That needs to be fixed in C but you can wrap your code into
try - except
guards for now in Python like so
try:
device_list = device.getDeviceList()
except:
pass
I managed to get a fix:
static PyObject *
getDeviceList(PyObject *self, PyObject *args)
{
PyObject* pyList = NULL;
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
//backup; run it without multithreading.
if (!SUCCEEDED(hr))
{
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
}
if (SUCCEEDED(hr))
{
IEnumMoniker *pEnum;
hr = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum);
if (SUCCEEDED(hr))
{
pyList = DisplayDeviceInformation(pEnum);
pEnum->Release();
}
CoUninitialize();
} else {
PyErr_SetString(PyExc_TypeError, "Could not call CoInitializeEx");
}
return pyList;
}
Related, possibly duplicate: #5
In case anyone stumbles onto this, I am still getting this error in windows-capture-device-list==1.1.0 on Windows 11.
I am using Windows 11. Just a few code changes and this error appears. I don't know what the cause is.
In my environment, the following code gives me an error.
from distutils.dir_util import copy_tree
import device
device_list = device.getDeviceList()
print(device_list)
The following code does not produce an error.
import device
device_list = device.getDeviceList()
print(device_list)
However, it seems that not only "distutils.dir_util" is affected, but also other libraries.
hello~ I got this error when i use window 7 x64 , but everything is OK in win10. How can I fix it?