WPD获得媒体维度

时间:2017-12-20 15:04:50

标签: c++ wpd

我想通过IPortableDeviceValues获取WPD上图像文件的宽度和高度。

根据Windows Dev Center每个类型为WPD_CONTENT_TYPE_IMAGE(它们是)的对象需要提供WPD_MEDIA_WIDTH / WPD_MEDIA_HEIGHT,但我总是收到错误。

HRESULT MyPortableDevice::getIntValue(IPortableDeviceProperties* properties, PCWSTR objectID, const PROPERTYKEY& key, DWORD* value)
{

ComPtr<IPortableDeviceValues>        objectProperties;
ComPtr<IPortableDeviceKeyCollection> propertiesToRead;

HRESULT hr = CoCreateInstance(CLSID_PortableDeviceKeyCollection,
                              nullptr,
                              CLSCTX_INPROC_SERVER,
                              IID_PPV_ARGS(&propertiesToRead));

if (SUCCEEDED(hr)) {
    HRESULT tempHr = S_OK;
    tempHr = propertiesToRead->Add(key);      
}

if (SUCCEEDED(hr)) {
    hr = properties->GetValues(objectID,                
                               propertiesToRead.Get(),  
                               &objectProperties); 
}   

if (SUCCEEDED(hr)) {

    ULONG intValue = 0;
    hr = objectProperties->GetUnsignedIntegerValue(key, &intValue);

    if (SUCCEEDED(hr)) {          
        value = &intValue;
        intValue = 0;
    }            
}

return hr;

我总是从

获得错误值
hr = objectProperties->GetUnsignedIntegerValue(key, &intValue);

hr = 0x80070490,我找不到此错误代码here

有谁知道什么是错的?

1 个答案:

答案 0 :(得分:0)

你得到的错误是: 错误代码:(HRESULT)0x80070490(2147943568) - 找不到元素。

您最常得到此错误的原因是,实际上手机应用程序开发人员通常会忽略某些属性。

我已将手机连接到PC,并使用WPD Information Tool检查了一些图片,我只获得了.jpg截图的字段: enter image description here

我认为在大多数情况下,您需要阅读图片内容以直接流式传输并检查其参数。也许在某些格式中,您只能阅读一些“标题”部分并从那里获得宽度和高度。