parent
527752a588
commit
63cea2ae22
5 changed files with 99 additions and 0 deletions
@ -0,0 +1,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; |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
project('diatest', 'cpp') |
||||
|
||||
if host_machine.system() != 'windows' |
||||
error('MESON_SKIP_TEST: unsupported platform') |
||||
endif |
||||
cpp = meson.get_compiler('cpp', native: false) |
||||
is_msvc_clang = cpp.get_id() == 'clang' and cpp.get_define('_MSC_VER') != '' |
||||
if not ['msvc', 'clang-cl'].contains(cpp.get_id()) and not is_msvc_clang |
||||
error('MESON_SKIP_TEST: unsupported compiler') |
||||
endif |
||||
|
||||
dia = dependency('diasdk', required: true) |
||||
executable('dia_registered', ['dia_registered.cpp'], dependencies:[dia]) |
@ -0,0 +1,3 @@ |
||||
#pragma once |
||||
|
||||
#define MSDIA_DLL_NAME L"@msdia_dll_name@" |
@ -0,0 +1,32 @@ |
||||
// Loads msdiaXXX.dll from current directory using NoRegCoCreate.
|
||||
// File name is set in config.h symbol MSDIA_DLL_NAME.
|
||||
|
||||
#include <dia2.h> |
||||
#include <diacreate.h> |
||||
#include <windows.h> |
||||
#include <stdexcept> |
||||
#include <iostream> |
||||
|
||||
#include "config.h" |
||||
|
||||
int main() |
||||
{ |
||||
try { |
||||
|
||||
HRESULT hr = CoInitialize(NULL); |
||||
if (FAILED(hr)) |
||||
throw std::runtime_error("Failed to initialize COM library"); |
||||
|
||||
IDiaDataSource* datasrc; |
||||
hr = NoRegCoCreate(MSDIA_DLL_NAME, CLSID_DiaSource, __uuidof(IDiaDataSource), (void**)&datasrc); |
||||
if (FAILED(hr)) |
||||
throw std::runtime_error("Can't open DIA DLL"); |
||||
|
||||
std::cout << "DIA was successfully loaded\n"; |
||||
return 0; |
||||
|
||||
} catch (std::exception& err) { |
||||
std::cerr << err.what() << std::endl; |
||||
return 1; |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
project('diatest', 'cpp') |
||||
|
||||
if host_machine.system() != 'windows' |
||||
error('MESON_SKIP_TEST: unsupported platform') |
||||
endif |
||||
cpp = meson.get_compiler('cpp', native: false) |
||||
is_msvc_clang = cpp.get_id() == 'clang' and cpp.get_define('_MSC_VER') != '' |
||||
if not ['msvc', 'clang-cl'].contains(cpp.get_id()) and not is_msvc_clang |
||||
error('MESON_SKIP_TEST: unsupported compiler') |
||||
endif |
||||
|
||||
dia = dependency('diasdk', required: true) |
||||
dia_dll_name = dia.get_variable('dll') |
||||
fs = import('fs') |
||||
fs.copyfile( dia_dll_name ) |
||||
|
||||
conf = configuration_data() |
||||
conf.set('msdia_dll_name', fs.name(dia_dll_name)) |
||||
configure_file(input: 'config.h.in', output: 'config.h', configuration: conf) |
||||
|
||||
executable('dia_from_dll', ['dia_from_dll.cpp'], dependencies: [dia]) |
Loading…
Reference in new issue