www.digitalmars.com         C & C++   DMDScript  

D - Using Existing COM/OLE in D

reply J C Calvarese <jcc-47 excite.com> writes:
I've been trying to use some of Microsoft's COM interfaces in D 
(IPicture and IShellLink).  I've gotten both attempts to compile but 
they don't run correctly (they yield runtime errors before they do 
anything useful).  I've attached the IShellLink attempt in case anyone 
is interested in my approach.  I was trying to use it to create a shortcut.

I was wondering if anyone has successfully used an existing COM 
interface in D.  I know the dmd\samples folder has an example of 
creating a COM client/server in D, but I was wondering if there are any 
examples around with using an interface created in another language. 
I've found examples in C, C++, and Delphi, but I don't I've guessed 
correctly how to do it it D.  I don't know much about COM, but I can be 
pretty stubborn and I've got C code of these programs (using IPicture 
and IShellLink) that I know work.

I'd appreciate any suggestions.  Thanks.

Justin
Mar 29 2003
parent reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
it works .....

you need extern( Windows ){ ... interfaces .... }

and

in D 'IShellLink obj;'  is the the same as the C 'IShellLink * obj;'
thus
&obj is in C a void** (for the CoCreateInstance last param)

Hope this helps .

"J C Calvarese" <jcc-47 excite.com> wrote in message
news:b65i0q$kb5$1 digitaldaemon.com...
 I've been trying to use some of Microsoft's COM interfaces in D
 (IPicture and IShellLink).  I've gotten both attempts to compile but
 they don't run correctly (they yield runtime errors before they do
 anything useful).  I've attached the IShellLink attempt in case anyone
 is interested in my approach.  I was trying to use it to create a
shortcut.
 I was wondering if anyone has successfully used an existing COM
 interface in D.  I know the dmd\samples folder has an example of
 creating a COM client/server in D, but I was wondering if there are any
 examples around with using an interface created in another language.
 I've found examples in C, C++, and Delphi, but I don't I've guessed
 correctly how to do it it D.  I don't know much about COM, but I can be
 pretty stubborn and I've got C code of these programs (using IPicture
 and IShellLink) that I know work.

 I'd appreciate any suggestions.  Thanks.

 Justin
begin 666 createLink.d M:&]R=&-U="!T;R!A;B!E>&5C=71A8FQE+"!A9&1I;F< <V5V97)A;"!P<F]P M;W=S($%022!C;VYS=&%N=', *B\-" T*8V]N<W0 :6YT(%-77U-(3U< /34[ M1$5&24Y%7U-(3$=5240H;F%M92P ;"P =S$L('<R*2!$149)3D5?1U5)1"AN M4VAE;&Q,:6YK02 (" (#T M,' T-EU].PT*97AT97)N*%=I;F1O=W,I(&-O;G-T($E)1"!)241?25!E<G-I M?3L-"F%L:6%S($E)1%])4VAE;&Q,:6YK02!)241?25-H96QL3&EN:SL-" T* M:6%S($E414U)1$Q)4U0J($Q0251%34E$3$E35#L- M,S)?1DE.1%]$051!( T*>PT*(" ($173U)$(&1W1FEL94%T=')I8G5T97,[ M9G1,87-T06-C97-S5&EM93L-"B ("!&24Q%5$E-12!F=$QA<W17<FET951I M(" (&-H87( 8T%L=&5R;F%T949I;&5.86UE6S$T73L-"B ("!73U)$(&1U M;6UY.PT*?2 -"F%L:6%S(%=)3C,R7T9)3D1?1$%402H 3%!724XS,E]&24Y$ M(" 1%=/4D0 ;D9I;&53:7IE2&EG:#L-"B ("!$5T]21"!N1FEL95-I>F5, M05( 8T%L=&5R;F%T949I;&5.86UE6S$T73L-"B ("!73U)$(&1U;6UY.PT* M?0T*86QI87, 5TE.,S)?1DE.1%]$051!02H 3%!724XS,E]&24Y$7T1!5$%! M+"!05TE.,S)?1DE.1%]$051!03L-" T*<W1R=6-T(%=)3C,R7T9)3D1?1$%4 M(" ($9)3$5424U%(&9T0W)E871I;VY4:6UE.PT*(" (" ("!&24Q%5$E- M12!F=$QA<W1!8V-E<W-4:6UE.PT*(" (" ("!&24Q%5$E-12!F=$QA<W17 M(" ($173U)$(&Y&:6QE4VEZ94QO=SL-"B (" (" 1%=/4D0 9'=297-E M0TA!4B!C1FEL94YA;65;34%87U!!5$A=.PT*(" (" ("!70TA!4B!C06QT M97)N871E1FEL94YA;65;,31=.PT*(" (" ("!73U)$(&1U;6UY.PT*?0T* M86QI87, 5TE.,S)?1DE.1%]$051!5RH 3%!724XS,E]&24Y$7T1!5$%7+"!0 M*3L-" T*86QI87, 365S<V%G94)O>$$ 365S<V%G94)O>#L- M(&]B:FED;"YH(&5X8V5R<'0 *B\-" T*97AT97)N*%=I;F1O=W,I("\K8V]N M<W0K+R!E>'1E<FX 24E$("\K24E$7TE097)S:7-T1FEL92LO($E)1%])4$52 M($E097)S:7-T1FEL93H 255N:VYO=VX-"GL-"B\K(" ($A215-53%0 *%]S M=&1C86QL("I1=65R>4EN=&5R9F%C92DH25!E<G-I<W1&:6QE*BQ2149)240L M:7-T1FEL92HI.PT*(" (%5,3TY'("A?<W1D8V%L;" J4F5L96%S92DH25!E M<G-I<W1&:6QE*BD[*R\-"B ("!(4D5354Q4($=E=$-L87-S240H0TQ3240J M*3L-"B ("!(4D5354Q4($ES1&ER='DH*3L-"B ("!(4D5354Q4($QO860H M:FED;"YH(&5X8V5R<'0 *B\-" T*:6YT97)F86-E($E097)S:7-T241,:7-T M.B!)56YK;F]W; T*>PT*+RL ("!(4D5354Q4(%%U97)Y26YT97)F86-E*%)% M8V4 25-H96QL3&EN:SH 255N:VYO=VX-"GL-"B\K(" 2%)%4U5,5"!1=65R M>4EN=&5R9F%C92A2149)240L('9O:60 *BHI.PT*(" 54Q/3D< 061D4F5F M:"A,4%-44BP :6YT+"!724XS,E]&24Y$7T1!5$%!*BP 1%=/4D0I.PT*(" M(%-E=$E$3&ES="A,4$-)5$5-241,25-4*3L-"B ($A215-53%0 1V5T1&5S M3%0 1V5T2&]T:V5Y*%=/4D0J*3L-"B ($A215-53%0 4V5T2&]T:V5Y*%=/ M4D0I.PT*(" 2%)%4U5,5"!'9713:&]W0VUD*&EN="HI.PT*(" 2%)%4U5, M;BA,4%-44BP :6YT+"!I;G0J*3L-"B ($A215-53%0 4V5T26-O;DQO8V%T M:6]N*$Q00U-44BP :6YT*3L-"B ($A215-53%0 4V5T4F5L871I=F50871H M*$Q00U-44BP 1%=/4D0I.PT*(" 2%)%4U5,5"!297-O;'9E*$A73D0L($17 M;"!F=6YC=&EO;G, *B\-" T*8VAA<EM=($QE9G0H8VAA<EM=(',L(&EN="!L M96YG*0T*>PT*(" ("\J($QE9G0D*',D+"!L96YG*2 J+PT*(" (&EF("AL M96YG(#P](',N;&5N9W1H*2!R971U<FX <ULP+BYL96YG73L-"B ("!R971U M"GL-"B +RH +2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2T-"B (" M1$530U))4%1)3TXZ($=E=', 82!P871H(&9R;VT 9G5L;"!P871H(&YA;64- M"B (" (" (" 24Y0550Z(%-T<FEN9R!T;R!F=6QL('!A=& ;F%M90T* M(" (" (" ($]55%!55#H 4W1R:6YG('1O('!A=& ;F%M90T*(" (" M(" ("!54T%'13H 8G5F9F5R)" ]($%P<%!A=& D*")C.EQY;W5R(&1I<F5C M=&]R>5QY;W5R(&9I;&4N97AE(BD-"B (" (" (%)%5%523E,Z(&,Z7'EO M=7( 9&ER96-T;W)Y7 T*(" (" M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2 J+PT*(" (')E='5R;B!,969T*'!A=& L("\K3&%S=%!O<T-H87(H M3V)J+"!C:&%R6UT ;'!S>E!A=&A,:6YK+" 8VAA<EM=(&QP<WI$97-C+"!C M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2TM+0T*(" (" 1$530U))4%1)3TXZ($-R96%T97, 82!7:6YD M12P <W1R:6YG('1O('-H;W)T8W5T+"!S=')I;F< =&\ 9&5S8W)I<'1I;VXL M(" 3U544%54.B!(4D5354Q4('1O('-U8V-E<W, ;W( 9F%I;'5R90T*(" M(" (" (" 55-!1T4Z(')E<W5L=" ]($-R96%T94QI;FLH(F,Z7&EN+F5X M92(L(")C.EQO=70N;&YK+" B9&5S8W)I<'1I;VXB*0T*(" (" (" (%)% M5%523E,Z(%-?3TL :68 =&AE(&EN=&5R9F%C92!I<R!S=7!P;W)T960L($5? M3D])3E1%4D9!0T4 :68 ;F]T+ T*(" (" +2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M4&%T:$]B:CHG)2XJ<R<L(&QP<WI0871H3&EN:SHG)2XJ<R<L(&QP<WI$97-C M.B<E+BIS)RP ;'!S>DEC;VXZ)R4N*G,G*5QN(BP ;'!S>E!A=&A/8FHL(&QP M:6YK(&EN=&5R9F%C92X *B\-"B ("!H<F5S(#T M140H:')E<RDI( T*(" ('L-"B (" (" 25!E<G-I<W1&:6QE('!P9CL- M"DUE<W-A9V5";W H;G5L;"P (DQI;F4 ,C4W(2(L(" B0VAE8VMP;VEN="(L M"0D (&-H87( *B!P='( /2!C87-T*&-H87(J*2 H;'!S>E!A=&A/8FH ?B!< M('!S;"Y39710871H*"!P='( *3L (" O*B!4:&ES(&ES('=H97)E(")%<G)O M("\J(%-E=', <VAO<G1C=70 9&5S8W)I<'1I;VX *B\-"B (" (" <'-L M+E-E=$1E<V-R:7!T:6]N*&-A<W0H8VAA<BHI("AL<'-Z1&5S8R!^(%PP*2D[ M(" ("!P<VPN4V5T26-O;DQO8V%T:6]N*&-A<W0H8VAA<BHI("AL<'-Z26-O M;B J+PT*(" (" ("!P<VPN4V5T4VAO=T-M9"A35U]32$]7*3L +RH 34%8 M(" (" ("!P<VPN4V5T5V]R:VEN9T1I<F5C=&]R>2A!<'!0871H*&QP<WI0 M(" (" <'-L+E-E=$%R9W5M96YT<R B+6%R9S$ +6%R9S( +6%R9S,B*3L M+RI53D-/34U%3E0 5$A)4R!)1B!93U4 5T%.5"!43R!3150 05)'54U%3E13 M*B\-" T*+RL (" (" ("\J("HJ*BH 3W1H97( <')O<&5R=&EE<R!A<F4 M;FQE<W, >6]U(&1E9FEN92!T:&4 ;W1H97( <&%R86UE=&5R<RX-"B (" M(" ("!296%D('1H92!-:6-R;W-O9G0 4%-$2R!F;W( ;6]R92!I;F9O+B J M(" <'-L+E-E=$E$3&ES="AP:61L*3L-"B (" (" ("!P<VPN4V5T4F5L M(%%U97)Y($E3:&5L;$QI;FL 9F]R('1H92!)4&5R<VES=$9I;&4 :6YT97)F M86-E(&9O<B!S879I;F< =&AE( T*(" (" (" ("!S:&]R=&-U="!I;B!P M<GE);G1E<F9A8V4H)DE)1%])4&5R<VES=$9I;&4 +RM)241?25!%4E-)4U1& M0T-%141%1"AH<F5S*2D-"B (" (" >R -"B (" (" (" (%=/4D0 M=W-Z6TU!6%]0051(73L-"B -"B (" (" (" ("\J($5N<W5R92!T:&%T M('1H92!S=')I;F< :7, 04Y322X *B\-"B (" (" (" ($UU;'1I0GET M951O5VED94-H87(H0U!?04-0+" P+"!L<'-Z4&%T:$QI;FLL("TQ+"!W<WHL M($U!6%]0051(*3L-"B -"B (" (" (" ("\J(%-A=F4 =&AE(&QI;FL M("!H<F5S(#T <'!F+E-A=F4H8V%S="AW8VAA<BHI('=S>BP 8V%S="AI;G0I M('1R=64I.PT*(" (" (" (" <'!F+E)E;&5A<V4H*3L-"B (" (" M?0T*(" (" ("!P<VPN4F5L96%S92 I.PT*(" ('T-" T*(" ($-O56YI M;FET:6%L:7IE*"D[("\J(%5N:6YI=&EA;&EZ92!T:&4 0T]-(&]B:F5C=" J M( T*(" (&-H87);72!30U!A=& /2 G0SI<=VEN;G1<)SL-"B ("!C:&%R M6UT <WI&:6QE.PT*(" (&-H87);72!S>E1A<F=E=#L-"B ("!C:&%R6UT M<WI&:6QE(" /2!30U!A=& ?B G97AP;&]R97(N97AE)SL-"B ("!S>E1A M(#T )T,Z7'-T;W)E7&0M;&%N9RUL:6)S7&-R96%T94QI;FM<9FQD<E]!+FEC M<BYE>&4G+" G0SI<=VEN;G1<5FES:61A=&$N;&YK)RP (E-H;W)T8W5T('1O M('1E<W0N;&YK('5S:6YG($0A(BP )T,Z7'-T;W)E7&0M;&%N9RUL:6)S7&-R M96%T94QI;FM<9FQD<E]!+FEC;R<I(#T M9V5";W H;G5L;"P (BHJ(%EO=7( <VAO<G1C=70 :&%S(&)E96X 8W)E871E M9"$B+" (DQO;VL 870 =&AA="P 1"!D;V5S(&1O($-/32$B+" P*3L-"B M(&]C8W5R960 =VAI;&4 =')Y:6YG('1O(&-R96%T92!Y;W5R('-H;W)T8W5T M>D9I;&4L('-Z5&%R9V5T+"!S>D1E<V,L('-Z26-O;BD /3T 4U]/2RD-"B M(" (" 365S<V%G94)O>"AN=6QL+" B66]U<B!S:&]R=&-U="!H87, 8F5E M;B!C<F5A=&5D(2(L(" B3&]O:R!A="!T:&%T+"!$(&1O97, 9&\ 0T]-(2(L M97)R;W( ;V-C=7)E9"!W:&EL92!T<GEI;F< =&\ 8W)E871E('EO=7( <VAO ` end
Mar 29 2003
parent J C Calvarese <jcc-47 excite.com> writes:
Mike Wynn wrote:
 it works .....
 
Thank you very much. Amazing. Yes, it does work. Justin
Mar 29 2003