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

FrankLike 1150015857 at qq.com
Thu Feb 22 13:31:52 UTC 2018


On Thursday, 22 February 2018 at 13:15:11 UTC, rikki cattermole 
wrote:

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

Thank you,but get the same error.

[D CODE]

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

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

-------------------log info--------------
CoCreateInstance
   pLink is 5E9954
will QueryInterface hr is 0
const(GUID)(267, 0, 0, [192, 0, 0, 0, 0, 0, 0, 70])
Access Violation

-----------------------end----------------------------
Thanks.


More information about the Digitalmars-d-learn mailing list