On 23/02/2018 2:12 AM, FrankLike wrote:
Hi,everyone,
 I want use the Com object (it comes from other dll) in D,but the core.sys.windows.objidl:QueryInterface Fuction not work.
For example:


import core.sys.windows.windef;
import core.sys.windows.basetyps;
import core.sys.windows.uuid;
import core.sys.windows.com;
import core.sys.windows.objbase:CoInitialize,CoUninitialize,CoCreateInstance;
import core.sys.windows.objidl;//:QueryInterface
import core.sys.windows.shlobj;//:IShellLink
import core.sys.windows.unknwn;

     if(lpszLnkFileDir is null) return;
     HRESULT hr;
     IShellLink* pLink;
     IPersistFile* ppf;

    hr = CoCreateInstance(&CLSID_ShellLink,NULL, CLSCTX_INPROC_SERVER,&IID_IShellLinkA,cast(PVOID*)&pLink);//cast(PVOID*)

     writeln("CoCreateInstance ");
     if(FAILED(hr))
     {
         writeln("FAILED(hr) ");
         return ;
     }
     writeln("  pLink is "~pLink.to!string);
     writeln("will QueryInterface hr is "~hr.to!string);
     writeln(IID_IPersistFile.to!string);
    hr = pLink.QueryInterface(&IID_IPersistFile, cast(PVOID*)&ppf);// err <-
     writeln("pLink.QueryInterface ");

-----------------------------------------------------
It stops in 'hr = pLink.QueryInterface(&IID_IPersistFile, cast(PVOID*)&ppf);'
But  the same c++ code is ok.
Who can help me?
Thanks.

Reminder classes in D are already references, no need for pointers to them.

Reply via email to