Search code examples
windowswinapicomd

Can I use routines from comdef.h, Wbemidl.h etc in D?


I know to windows.h header, there's D's module:

core.sys.windows.windows

but about ones like this:

#include <comdef.h>
#include <Wbemidl.h>

does D support them and if so, how do I import


Solution

  • I am not a Windows programming guru, but I am quite sure you will have to write a wrapper around the wbemuuid.lib library yourself, as compilers usually do not supply it by default. As you know, you can use any C function from any core Windows library.

    Just by looking at Wbemidl.h file from the MinGW project it seems like you will have lots of work to do. - You will have to wrap wbemcli.h, wbemprov.h, wbemtran.h and wbemdisp.h.

    Take a look at std/c/windows/com.d how to do it. There are several WindowsAPI related projects, one of them is this one: http://dsource.org/projects/bindings/wiki/WindowsApi . It will help you start.

    From personal perspective, I believe the best approach is to have bindings/wrappers per WindowsAPI library. In this case I would create wbemuuid package, and wbemcli, wbemprov, wbemtran and wbemdisp modules inside this package.

    Finally, you most likely want to analyse existing COM support in D. And Lionello's "Modern COM Programming in D" slides.