VRAM Usage in C++

Is there a way to obtain the VRAM usage in C++? I would like to expose it to Blueprints and use it in a widget to display on screen. Thanks!

Well, I did find a way of getting the VRAM usage, but it’s very unconvential.

#include <dxgi1_4.h>

IDXGIFactory4* pFactory;
CreateDXGIFactory1(__uuidof(IDXGIFactory4), (void**)&pFactory);

IDXGIAdapter3* adapter;
pFactory->EnumAdapters(0, reinterpret_cast<IDXGIAdapter**>(&adapter));

DXGI_QUERY_VIDEO_MEMORY_INFO videoMemoryInfo;
adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &videoMemoryInfo);

return (int64)videoMemoryInfo.CurrentUsage / 1024 / 1024;

Unfortunately, I keep getting errors such as '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' unless I disable them in Target.cs using bEnableUndefinedIdentifierWarnings = false; which feels like bad practice.

(But then so is directly calling DirectX APIs…)