Article View: borland.public.cppbuilder.nativeapi
Article #10426Re: COM (BCB6)
From: Bob Gonder
Date: Thu, 29 Apr 2004 16:51
Date: Thu, 29 Apr 2004 16:51
61 lines
2342 bytes
2342 bytes
Oliver Young wrote:
>
> Yes, I know this is not proper newsgroup to ask, but I have to. :< I'm
>asking this question for past 6 months and no answer. I'm trying to
>translate JScript (or Delphi) code into C++ (BCB6). Please help.
>
>*** This is Delphi code: ***
>
>program Project1;
>{$APPTYPE CONSOLE}
Console App....
int main(void)
{
return 0;
}
>uses
> SysUtils, ComObj, Windows, Classes, ActiveX, Variants;
>
>var
> MyApp, prop, res: Variant;
>
>begin
> CoInitialize(nil);
CoInitialize(NULL);
>
> MyApp := CreateOleObject('MyCOM.MyApp.1');
>
> prop := MyApp.CreatePropObject;
> prop.Param1 := 'Some text here';
> prop.Param2 := '';
> prop.Param3 := True;
> prop.Param4 := True;
>
> res := MyApp.MyFunction(prop);
MyFunction( "Some text here" );
> WriteLn( 'Error: ' + VarToStr(res.error));
char ErrorString[1024];
wsprintf( ErrorString, "Error: %i\r\n", res.error );
cputs( ErrorString );
>
> CoUninitialize();
>end.
Puting it all together:
int main(void)
{ char ErrorString[1024];
CoInitialize(NULL);
MyFunction( "Some text here" );
wsprintf( ErrorString, "Error: %i\r\n", res.error );
cputs( ErrorString );
CoUninitialize();
return 0; /* or return res.error */
}
Technical Details
Message-ID:
<o1c290l3jn2tugilemoihrlnnfrk57207h@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4090a604$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c2137044da8cd787 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-29 10:10:29 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: COM (BCB6) Date: Thu, 29 Apr 2004 09:51:31 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <o1c290l3jn2tugilemoihrlnnfrk57207h@4ax.com> References: <4090a604$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 65.160.211.44 X-Trace: newsgroups.borland.com 1083257490 65.160.211.44 (29 Apr 2004 09:51:30 -0700) Lines: 62 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail