Calling a C++ Object from D

Richard Webb webby at beardmouse.org.uk
Tue Jan 24 05:22:46 PST 2012


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);
      }
  }
}
///////////////////////


More information about the Digitalmars-d-learn mailing list