blob: cec4fb2f678fd2bee444cd6242e1bd91bfdecbb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Loads DIA SDK from system registry using CoCreateInstance().
// The corresponding msdiaXXX.dll must be registered in system registry
// (eg. run `regsvr32.exe msdia140.dll` as administrator)
#include <dia2.h>
#include <windows.h>
#include <stdexcept>
#include <iostream>
int main()
{
try {
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
throw std::runtime_error("Failed to initialize COM library");
IDiaDataSource* datasrc;
hr = CoCreateInstance( CLSID_DiaSource, NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiaDataSource), (void **)&datasrc);
if (FAILED(hr))
throw std::runtime_error("Can't create IDiaDataSource. You must register msdia*.dll with regsvr32.exe.");
std::cout << "DIA was successfully loaded\n";
return 0;
} catch (std::exception& err) {
std::cerr << err.what() << std::endl;
return 1;
}
}
|