Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C or C++ for OLE interface implementation.

2 views
Skip to first unread message

Weiqi Gao

unread,
Aug 26, 1996, 3:00:00 AM8/26/96
to

Hello, OLE world!

I'm actually reading the Inside OLE book from cover to cover, so that
instead of talking the "OLE talk", I can actually grasp the meaning of it
all. And I have several (I think elementary) questions. (I'm in chapter 2
now, I accepted chapter 1 in its face value.)

1. When it is said that an OLE interface can be implemented in either C or
C++, and then can be accessed from either C or C++, does it imply that the
C implementation has to fake a C++ class (for accessing an interface
implementation written in C from a C++ client)?

Doesn't it depend on the specific C++ compiler (I am thinking about the
impossibility of using a Borland C++ compiled C++ class from Visual C++.
In other words, which C++ compiler's C++ class does the C implementation
have to fake)?

2. When I checked on-line help for CoBuildVersion(), the answer is "this
function is obsolete." What functionality does it use to have? And what
is the replacement of this function?

3. What exactly does CoInitialize() do?

--
Weiqi Gao
weiq...@crl.com

Charlie Kindel

unread,
Aug 27, 1996, 3:00:00 AM8/27/96
to

Weiqi Gao <weiq...@crl.com> wrote in article
<01bb9399$1b95c4a0$010200c0@peking-1>...

| 1. When it is said that an OLE interface can be implemented in either C
or
| C++, and then can be accessed from either C or C++, does it imply that
the
| C implementation has to fake a C++ class (for accessing an interface
| implementation written in C from a C++ client)?
| Doesn't it depend on the specific C++ compiler (I am thinking about the
| impossibility of using a Borland C++ compiled C++ class from Visual C++.
| In other words, which C++ compiler's C++ class does the C implementation
| have to fake)?

The core of COM is the specification of the binary, in-memory layout, of an
interface vtable. The layout COM uses just happens to be the same layout
that all popular C++ compilers use for their C++ vtable layouts. In C, you
just build one of these vtables yourself by allocating a chunk of memory
and filling it in with function pointers.

| 2. When I checked on-line help for CoBuildVersion(), the answer is "this
| function is obsolete." What functionality does it use to have? And what
| is the replacement of this function?

Back in the Win16 days the OLE/COM system DLLs were redistributable by
applications. That is, an OLE enabled application like Lotus 123 shipped
the "latest" verison of the OLE/COM DLLs and installed them as part of the
setup process (only if they were newer than any the user might already have
on his system). CoBuildVersion() allowed an application to verify it was
using the version of the DLLs it was written for. In Win32 systems the
OLE/COM system DLLs are included in the system and are not redistributed by
applications. The Win32 GetVersion() and GetVersionEx() APIs can be used to
determine what version of Win32 the app is running on.

| 3. What exactly does CoInitialize() do?

A bunch of stuff. Primarily, though, it creates a hidden window used by COM
for interprocess communication.

--
Charlie Kindel <mailto:cki...@microsoft.com>
COM/DCOM Program Management
All opinions expressed are mine, mine, mine!

Brian Coles

unread,
Aug 29, 1996, 3:00:00 AM8/29/96
to

> 1. When it is said that an OLE interface can be implemented in either C or
> C++, and then can be accessed from either C or C++, does it imply that the
> C implementation has to fake a C++ class (for accessing an interface
> implementation written in C from a C++ client)?
>
> Doesn't it depend on the specific C++ compiler (I am thinking about the
> impossibility of using a Borland C++ compiled C++ class from Visual C++.
> In other words, which C++ compiler's C++ class does the C implementation
> have to fake)?
>

I've successfully implemented an OLE interface using Borland C++. It
works when called from an MS VC++ application written by MS. Use the
"nested class" approach. I'll give you a sample layout if you like.

-- Brian Coles

Joe Hsu

unread,
Aug 31, 1996, 3:00:00 AM8/31/96
to

In article <01bb93ce$8f66b6c0$3016369d@ckindel-610>, "Charlie Kindel" <cki...@microsoft.com> wrote:

>| 3. What exactly does CoInitialize() do?
>
>A bunch of stuff. Primarily, though, it creates a hidden window used by COM
>for interprocess communication.

Charlie,

Why is a hidden window created for interprocess communication? I thought the
IPC is done through RPC. Shouldn't the RPC runtime take care of all the IPC
stuff?

It would make sense if a hidden window is created for an multithread apartment
model COM object.

Regards,


Joe Hsu . . . . . . . . . . . . . Citicorp/TTI
h...@tti.com . . . . . . . . . . . 3100 Ocean Park Blvd
310.450.9111 x3117 . . . . . . . . Santa Monica, Ca 90405
** Any comments or statements made are not necessarily **
** those of Citicorp, its subsidiaries or affiliates. **

Charlie Kindel

unread,
Sep 1, 1996, 3:00:00 AM9/1/96
to

Joe Hsu <h...@tti.com> wrote in article <Dwz83...@ttinews.tti.com>...

| Why is a hidden window created for interprocess communication? I thought
the
| IPC is done through RPC. Shouldn't the RPC runtime take care of all the
IPC
| stuff?
|
| It would make sense if a hidden window is created for an multithread
apartment
| model COM object.

If you use CoInitializeEx and specify free threaded then it is as you
describe. However, the original poster asked about CoInitialize, which is
equivalent to calling CoInitializeEx and specifying apartment model.

0 new messages