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

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 13:15:11 UTC, rikki cattermole 
wrote:

On 23/02/2018 2:12 AM, FrankLike wrote:



 IShellLink* pLink;
 IPersistFile* ppf;


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


Ok,I delete the pointers ,It's ok!

Thank you very much!


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

2018-02-22 Thread FrankLike via Digitalmars-d-learn
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.


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

2018-02-22 Thread rikki cattermole via Digitalmars-d-learn

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(_ShellLink,NULL, 
CLSCTX_INPROC_SERVER,_IShellLinkA,cast(PVOID*));//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(_IPersistFile, cast(PVOID*));// 
err <-

 writeln("pLink.QueryInterface ");

-
It stops in 'hr = pLink.QueryInterface(_IPersistFile, 
cast(PVOID*));'

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.



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

2018-02-22 Thread FrankLike via Digitalmars-d-learn

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(_ShellLink,NULL, 
CLSCTX_INPROC_SERVER,_IShellLinkA,cast(PVOID*));//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(_IPersistFile, 
cast(PVOID*));// err <-

writeln("pLink.QueryInterface ");

-
It stops in 'hr = pLink.QueryInterface(_IPersistFile, 
cast(PVOID*));'

But  the same c++ code is ok.
Who can help me?
Thanks.