www.digitalmars.com         C & C++   DMDScript  

D - DMD 0.79 com server and template problems - comserver.zip

I noticed that the sample self registering inprocess com server dll example had
a strange behaviour :
when the dll is unloaded (not sure why CoFreeLibrary was called and no
FreeLibrary) the console IO also stopped.
this can be solved by keeping the dll loaded until the app exits, this I assume
is due to the runtime lib shutdown code closing stdin/out/err
which my be an indiccator that there are other issues with dll's written in D
(apart from the multipul GC's that will be running [not nec a bad thing])


also I tried to use the template T(alias A) syntax to ease calling
CoCreateInstance

template ComCreate(alias clz_guid, alias if_guid, IFACE ) {
IFACE newInstance() {
HRESULT hr;
IFACE   obj;
hr = CoCreateInstance( &clz_guid, null, CLSCTX_ALL, &if_guid, &obj );
if ( FAILED( hr ) )
{
throw new Exception( "unable to create new instance" );
}
return obj;
}
}

called with 
pIHello = ComCreate!(CLSID_Hello, IID_IHello, IHello).newInstance();

this however gives the error 
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

dclient.obj(dclient)
Error 42: Symbol Undefined _D7dclient10IID_IHelloS3std1c7windows3com4GUID
dclient.obj(dclient)
Error 42: Symbol Undefined _D7dclient11CLSID_HelloS3std1c7windows3com4GUID
--- errorlevel 2

is this a problem with the compiler or with my code ?

the work around was to do

template ComCreate( IFACE ) {
IFACE newInstance(GUID * clz_guid, GUID * if_guid ) {
HRESULT hr;
IFACE   obj;
hr = CoCreateInstance( clz_guid, null, CLSCTX_ALL, if_guid, &obj );
if ( FAILED( hr ) )
{
throw new Exception( "unable to create new instance" );
}
return obj;
}
}

pIHello = ComCreate!(IHello).newInstance(&CLSID_Hello, &IID_IHello);



begin 0644 comserver.zip


MK4`!`0``[ $``!(```!C;VUS97)V97(O8G5I;&0N<VAED$UKPS`,AN^!_`=!
M=UBA26$[]S!:MDO*#F.W7


MK7)H &Q`=U%:.D_/0MU"H8$FVQZD$*';U52DK;4F&10.&94LOYI:5/H?,?72





MV:QX+Z#FE

MQ:9S '$68X&Q!34`/8!':[[Z/=U;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>P$``&-O;7-E<G9E<B]C:&5L;&\N
M9%!+`0(4`!0`` `(`+I.2S"CA?,KN 4``+P/```3``````````$`(````,8%
M``!C;VUS97)V97(O9&-L:65N="YD4$L!`A0`%``"`` `9 %+,"8.L8N`"P``
M"R8``!,``````````0` ````L0L``&-O;7-E<G9E<B]D<V5R=F5R+F102P$"
M%``4``(`"`!X&X,AE-E8'[<```!B`0``%0`````````!`"````!B%P``8V]M
M<V5R=F5R+V1S97)V97(N9&5F4$L!`A0`%``"`` `-P9+,)*7BGE\`0``>`(`
M`!(``````````0` ````3! ``&-O;7-E<G9E<B]I:&5L;&\N9%!+!08`````
!P`'`,8!``#X&0``````
`
end
Feb 11 2004