www.digitalmars.com         C & C++   DMDScript  

D - COM questions?

reply "Robert M. Münch" <robert.muench robertmuench.de> writes:
Hi, well I didn't got an answer to my first try :-(, so I try again:

I want to use some COM objects with D. Where do I get the interface
definition from? IUnknown is defined in com.d

interface IUnknown
{
    HRESULT QueryInterface(IID* riid, void** pvObject);
    ULONG AddRef();
    ULONG Release();
}

But for other COM objects? Do I have to build all those interfaces up
myself? Can I use typelibs?

--
Robert M. Münch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax   : +49 (0)721 8408 9112
Web   : http://www.robertmuench.de
Jan 15 2003
parent reply "Walter" <walter digitalmars.com> writes:
At the moment, you'll have to declare them yourself. Nobody has done the
work to make the .d imports for them.

"Robert M. Münch" <robert.muench robertmuench.de> wrote in message
news:b04fdh$8pl$1 digitaldaemon.com...
 Hi, well I didn't got an answer to my first try :-(, so I try again:

 I want to use some COM objects with D. Where do I get the interface
 definition from? IUnknown is defined in com.d

 interface IUnknown
 {
     HRESULT QueryInterface(IID* riid, void** pvObject);
     ULONG AddRef();
     ULONG Release();
 }

 But for other COM objects? Do I have to build all those interfaces up
 myself? Can I use typelibs?
Jan 16 2003
parent reply "Robert M. Münch" <robert.muench robertmuench.de> writes:
"Walter" <walter digitalmars.com> schrieb im Newsbeitrag
news:b071n7$1pb5$1 digitaldaemon.com...

 At the moment, you'll have to declare them yourself. Nobody has done the
 work to make the .d imports for them.
Hi, ok. I try to see if a tool can be done that takes a typelib and creates source-code. Robert
Jan 20 2003
parent reply "Robert M. Münch" <robert.muench robertmuench.de> writes:
"Walter" <walter digitalmars.com> schrieb im Newsbeitrag
news:b071n7$1pb5$1 digitaldaemon.com...

 At the moment, you'll have to declare them yourself. Nobody has done the
 work to make the .d imports for them.
Hi, one more question: Do I have to declare the complete interface or is it possible to only add a few functions to start with? Do I have to considere a specific order of entries in the interface declaration? IIRC these calls are translated into a VTBL lookup so IMO this might be the case. Robert
Jan 21 2003
parent reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
"Robert M. Münch" <robert.muench robertmuench.de> wrote in message
news:b0j3cn$2dh9$1 digitaldaemon.com...
 "Walter" <walter digitalmars.com> schrieb im Newsbeitrag
 news:b071n7$1pb5$1 digitaldaemon.com...

 At the moment, you'll have to declare them yourself. Nobody has done the
 work to make the .d imports for them.
Hi, one more question: Do I have to declare the complete interface or is
it
 possible to only add a few functions to start with? Do I have to considere
a
 specific order of entries in the interface declaration? IIRC these calls
are
 translated into a VTBL lookup so IMO this might be the case. Robert
no you must only define the new methods as in interface IDirectDrawPalette : IUnknown { /*** IUnknown methods ***/ // HRESULT QueryInterface( REFIID riid, LPVOID * ppvObj); // ULONG AddRef(); // ULONG Release(); /*** IDirectDrawPalette methods ***/ HRESULT GetCaps( LPDWORD ); HRESULT GetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY ); HRESULT Initialize( LPDIRECTDRAW, DWORD, LPPALETTEENTRY ); HRESULT SetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY ); } if not the vtbl ends up off by (in this case 3) Mike.
Jan 21 2003
parent reply "Robert M. Münch" <robert.muench robertmuench.de> writes:
"Mike Wynn" <mike.wynn l8night.co.uk> schrieb im Newsbeitrag
news:b0j4pl$2e73$1 digitaldaemon.com...

 no you must only define the new methods as in

 interface IDirectDrawPalette : IUnknown
 {
  /*** IUnknown methods ***/
 // HRESULT QueryInterface( REFIID riid, LPVOID * ppvObj);
 // ULONG   AddRef();
 // ULONG   Release();
  /*** IDirectDrawPalette methods ***/
  HRESULT GetCaps( LPDWORD );
  HRESULT GetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY );
  HRESULT Initialize( LPDIRECTDRAW, DWORD, LPPALETTEENTRY );
  HRESULT SetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY );
 }
Hi, ok but I need to use the same order as MS did otherwise lookups in the VTBL will be screwed up. So I tried to get the above interface running but encountered further problems: 1. I need the CLSID and the IID. I extracted these values from the MS header files. 2. The LPDIRECTDRAW symbol isn't defined for D yet. The LPPALETTEENTRY is defined in win32.d, which isn't compatible with windows.d ... :-(( Walter, would it be possible that we move to win32.d ? IMO there are much more symbols in it. It's really annoying to have two "header" files that are incompatible. Robert
Jan 27 2003
parent reply "Sean L. Palmer" <seanpalmer directvinternet.com> writes:
I have a bunch of DirectX header stuff ported for D. (ok, so it was like DMD
version 0.39 or something)

Drop me a direct email if you want them.

I wonder if it's possible to have #import for DLL's or typelib's, for D?

other M$ libraries too.

Sean

"Robert M. Münch" <robert.muench robertmuench.de> wrote in message
news:b13ftp$22pu$1 digitaldaemon.com...
 "Mike Wynn" <mike.wynn l8night.co.uk> schrieb im Newsbeitrag
 news:b0j4pl$2e73$1 digitaldaemon.com...

 no you must only define the new methods as in

 interface IDirectDrawPalette : IUnknown
 {
  /*** IUnknown methods ***/
 // HRESULT QueryInterface( REFIID riid, LPVOID * ppvObj);
 // ULONG   AddRef();
 // ULONG   Release();
  /*** IDirectDrawPalette methods ***/
  HRESULT GetCaps( LPDWORD );
  HRESULT GetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY );
  HRESULT Initialize( LPDIRECTDRAW, DWORD, LPPALETTEENTRY );
  HRESULT SetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY );
 }
Hi, ok but I need to use the same order as MS did otherwise lookups in the VTBL will be screwed up. So I tried to get the above interface running but encountered further problems: 1. I need the CLSID and the IID. I extracted these values from the MS
header
 files.

 2. The LPDIRECTDRAW symbol isn't defined for D yet. The LPPALETTEENTRY is
 defined in win32.d, which isn't compatible with windows.d ... :-((

 Walter, would it be possible that we move to win32.d ? IMO there are much
 more symbols in it. It's really annoying to have two "header" files that
are
 incompatible. Robert
Jan 27 2003
next sibling parent "Robert M. Münch" <robert.muench robertmuench.de> writes:
"Sean L. Palmer" <seanpalmer directvinternet.com> schrieb im Newsbeitrag
news:b13sv6$2akp$1 digitaldaemon.com...

 I wonder if it's possible to have #import for DLL's or typelib's, for D?

 other M$ libraries too.
Hi, IMO this would really be cool! Using D for COM development could be the killer application for D. The MS environment setup is just to big for a quick development. What I'm dreaming about is using D and some available COM files and that's it. My current goal is to use MS Word as a COM object in a D project. It looks like this is a real challange... Robert
Jan 28 2003
prev sibling parent reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
how complete are you DirectX headers, there realy should be a combined
effort somewhere,  I have done the basic DirectX interface (explicit loading
of ddraw.dll, get the entry point etc)

I second the call for importing from dll;
one of the great delphi features (still IMHO does not outweight the horrid
syntax and dynamic array behaviour (which D has as well)) is the ability to
decare functions to import from dlls
in delphi the following
function getAHandle( a, b : LongInt ) : THandle; cdecl; extern mylib.dll;
will import a function from mylib.dll
which was compiled with the following C prototype
__declspec(dllexport) HANDLE getAHandle( long a, long b );

it would be nice to have
extern (C, mylib.dll) { HANDLE getAHamde( long a, long b ); }

and later when someone worked out how to connect a GC to a dll or app and
allow classes in dlls (like C++ can)
extern (D, mylib.dll) { MyObj getADHamde( long a, long b ); }
but more on that when I've worked out what is actually required.


"Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message
news:b13sv6$2akp$1 digitaldaemon.com...
 I have a bunch of DirectX header stuff ported for D. (ok, so it was like
DMD
 version 0.39 or something)

 Drop me a direct email if you want them.

 I wonder if it's possible to have #import for DLL's or typelib's, for D?

 other M$ libraries too.

 Sean

 "Robert M. Münch" <robert.muench robertmuench.de> wrote in message
 news:b13ftp$22pu$1 digitaldaemon.com...
 "Mike Wynn" <mike.wynn l8night.co.uk> schrieb im Newsbeitrag
 news:b0j4pl$2e73$1 digitaldaemon.com...

 no you must only define the new methods as in

 interface IDirectDrawPalette : IUnknown
 {
  /*** IUnknown methods ***/
 // HRESULT QueryInterface( REFIID riid, LPVOID * ppvObj);
 // ULONG   AddRef();
 // ULONG   Release();
  /*** IDirectDrawPalette methods ***/
  HRESULT GetCaps( LPDWORD );
  HRESULT GetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY );
  HRESULT Initialize( LPDIRECTDRAW, DWORD, LPPALETTEENTRY );
  HRESULT SetEntries( DWORD,DWORD,DWORD,LPPALETTEENTRY );
 }
Hi, ok but I need to use the same order as MS did otherwise lookups in
the
 VTBL will be screwed up.

 So I tried to get the above interface running but encountered further
 problems:

 1. I need the CLSID and the IID. I extracted these values from the MS
header
 files.

 2. The LPDIRECTDRAW symbol isn't defined for D yet. The LPPALETTEENTRY
is
 defined in win32.d, which isn't compatible with windows.d ... :-((

 Walter, would it be possible that we move to win32.d ? IMO there are
much
 more symbols in it. It's really annoying to have two "header" files that
are
 incompatible. Robert
Jan 28 2003
parent =?iso-8859-15?Q?=22Robert_M._M=FCnch=22?= <robert.muench robertmuench.de> writes:
On Wed, 29 Jan 2003 01:43:31 -0000, Mike Wynn <mike.wynn l8night.co.uk> 
wrote:

 how complete are you DirectX headers, there realy should be a combined
 effort somewhere,  I have done the basic DirectX interface (explicit 
 loading of ddraw.dll, get the entry point etc)
Hi, yes that's a good idea. Further I'm not only interested in DirectX but in other COM stuff too. For example using all the MS Office stuff via COM makes a lot of sense too. So a central D-COM ;-)) library would really be nice. What side is best suited to keep such an information? -- Robert M. Münch
Jan 28 2003