How to use Com object (it comes from other dll) in D? Thanks.

FrankLike 1150015857 at qq.com
Thu Feb 22 13:12:37 UTC 2018


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.



More information about the Digitalmars-d-learn mailing list