Get camera model from picture file in c++
See the question and my original answer on StackOverflowThere are multiple ways to do this. The most simple is to use the Shell API and query for the System.Photo.CameraModel property, something like this:
#include <windows.h>
#include <shobjidl_core.h>
#include <propkey.h>
#include <stdio.h>
int main()
{
CoInitialize(NULL);
IShellItem2* item;
if (SUCCEEDED(SHCreateItemFromParsingName(L"c:\\path\\photo.jpg", NULL, IID_PPV_ARGS(&item))))
{
LPWSTR str;
if (SUCCEEDED(item->GetString(PKEY_Photo_CameraModel, &str)))
{
wprintf(L"Model: %s\n", str);
CoTaskMemFree(str);
}
item->Release();
}
CoUninitialize();
return 0;
}