Calling a C++ Object from D

David Eagen spam_me_here at mailinator.com
Tue Jan 24 17:56:01 PST 2012


On Tue, 24 Jan 2012 07:22:46 -0600, Richard Webb <webby at beardmouse.org.uk>  
wrote:

> How about something like this (using Juno):
>
> ///////////////////////
> import juno.com.core, std.stdio;
>
> abstract final class SystemInformation {
>   mixin(uuid("C01B9BA0-BEA7-41BA-B604-D0A36F469133"));
>   mixin Interfaces!(ISystemInformation);
> }
>
> interface ISystemInformation : IDispatch
> {
>   mixin(uuid("ade87bf7-7b56-4275-8fab-b9b0e591844b"));
>
>   int get_OemHardwareSupportLink(wchar* retval);
>   int get_RebootRequired(out VARIANT_BOOL retval);
> };
>
> void main()
> {
>   //auto systemInformation =
> coCreate!(ISystemInformation)(uuidof!(SystemInformation));
>   auto systemInformation = SystemInformation.coCreate!ISystemInformation;
>
>   if (systemInformation !is null)
>   {
>       scope(exit) tryRelease(systemInformation);
>
>       VARIANT_BOOL b;
>       int result = systemInformation.get_RebootRequired(b);
>
>       if (SUCCEEDED(result))
>       {
> 	  writefln("Reboot Required: %s", b);
>       }
>   }
> }
> ///////////////////////

Thank you very much. This works great.

Yes, it turns out I was mistaken and this is COM and not C++. Juno  
definitely helps here. I cloned it from github and was glad to see that  
work had recently been done on Juno as well.

-Dave


More information about the Digitalmars-d-learn mailing list