| 1 |
// Loads msdiaXXX.dll from current directory using NoRegCoCreate. |
| 2 |
// File name is set in config.h symbol MSDIA_DLL_NAME. |
| 3 |
|
| 4 |
#include <dia2.h> |
| 5 |
#include <diacreate.h> |
| 6 |
#include <windows.h> |
| 7 |
#include <stdexcept> |
| 8 |
#include <iostream> |
| 9 |
|
| 10 |
#include "config.h" |
| 11 |
|
| 12 |
int main() |
| 13 |
{ |
| 14 |
try { |
| 15 |
|
| 16 |
HRESULT hr = CoInitialize(NULL); |
| 17 |
if (FAILED(hr)) |
| 18 |
throw std::runtime_error("Failed to initialize COM library"); |
| 19 |
|
| 20 |
IDiaDataSource* datasrc; |
| 21 |
hr = NoRegCoCreate(MSDIA_DLL_NAME, CLSID_DiaSource, __uuidof(IDiaDataSource), (void**)&datasrc); |
| 22 |
if (FAILED(hr)) |
| 23 |
throw std::runtime_error("Can't open DIA DLL"); |
| 24 |
|
| 25 |
std::cout << "DIA was successfully loaded\n"; |
| 26 |
return 0; |
| 27 |
|
| 28 |
} catch (std::exception& err) { |
| 29 |
std::cerr << err.what() << std::endl; |
| 30 |
return 1; |
| 31 |
} |
| 32 |
} |