0
我想调用一个名为StillIamge的接口调用名为GetDevicesList的方法调用,并获取空结果。我认为这是一个指针问题,但我不是C++专家,我认为这是问题所在。该方法的调用是:StillImage :: GetDeviceList指针
HRESULT GetDeviceList(
DWORD dwType,
DWORD dwFlags,
[out] DWORD *pdwItemsReturned,
[out] LPVOID *ppBuffer
);
我知道这是工作,当我进出诶返回设备2-14上升和下降塞成像设备。事实上,结果是空白的,我认为是由于我没有得到正确的指针 - 有人可以快速查看并让我知道,如果这是理由吗?
#include "stdafx.h"
bool debug = true;
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dwStiTotal = 0;
PSTI pSti = NULL;
HRESULT hres = StiCreateInstance(GetModuleHandle(NULL), STI_VERSION, &pSti, NULL);
STI_DEVICE_INFORMATION deviceInfo[255];
memset(deviceInfo,0, sizeof(deviceInfo));
hres = pSti->GetDeviceList(NULL, NULL, &dwStiTotal, (LPVOID*) deviceInfo);
printf("number devices %d\n", dwStiTotal);
for (int i=0; i<dwStiTotal; i++){
printf("---------------------------------------------------\n");
printf("type %d\n", deviceInfo[i].DeviceType);
printf("vendor %s\n", deviceInfo[i].pszVendorDescription);
printf("device %s\n", deviceInfo[i].pszDeviceDescription);
printf("portname %s\n", deviceInfo[i].pszPortName);
printf("PropProvider %s\n", deviceInfo[i].pszPropProvider);
printf("LocalName %s\n", deviceInfo[i].pszLocalName);
printf("InternalName %s\n", deviceInfo[i].szDeviceInternalName);
}
pSti->Release();
if (debug){
char key;
std::cin >> key;
}
return 0;
}
非常感谢您的提前和抱歉这样一个基本的问题!
问候,
尼尔
提问者的错误代码不会崩溃。 'GetDeviceList'将它分配的缓冲区地址写入您在最终参数中提供的指针大小的缓冲区。提问者提供更大的缓冲区,所以就API而言没有问题。 – arx
我认为它需要一个STI_DEVICE_INFORMATION数组。非常感谢,现在正在工作 - 你是一个明星! –