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

If I know the ID in GetIDsOfNames can I use this instead of the name?

0 views
Skip to first unread message

Moody

unread,
Mar 22, 2003, 2:13:46 PM3/22/03
to
I normally call my method from a VB client like this

beeper1.beep

If I know the method 'beep' has an id of 3 in GetIDsOfNames
is there a way to use this value instead of 'beep' i.e.

beeper.3 ( well, this didn't work, but is there some other way? )


Rogerio Wagner

unread,
Mar 23, 2003, 6:57:27 PM3/23/03
to
Hi Moody,

When you create you component in VB using early binding (type library
import) you are not using automation, cuz your call will be made through
v-table, the calls are made using IDispatch when you create component
instance using CreateObject(), and the calls can be made using
CallByName()....

[]'s
Roger
www.desenvolvendo.net

"Moody" <mo...@nospam.com> escreveu na mensagem
news:b5icl9$5oe$1...@titan.btinternet.com...

me@home

unread,
Mar 24, 2003, 6:01:27 AM3/24/03
to
I should make it clear what I mean: If for argument sake I would skip
the implementation of GetIDsOfNames, and just return a
"not implemented" error, will there be any other way to access my
methods (assuming it's not a dual interface, only IDispatch)

"Rogerio Wagner" <raw...@hotmail.com> wrote in message
news:e2Z5ggZ8...@TK2MSFTNGP11.phx.gbl...

Craig Powers

unread,
Mar 24, 2003, 10:21:24 AM3/24/03
to
"me@home" wrote:
>
> I should make it clear what I mean: If for argument sake I would skip
> the implementation of GetIDsOfNames, and just return a
> "not implemented" error, will there be any other way to access my
> methods (assuming it's not a dual interface, only IDispatch)

Sure, IDispatch::Invoke. That's what GetIDsOfNames gets called for
anyway, so that the calling routine knows what ID to pass to Invoke.

--
Craig Powers
MVP - Visual C++

me@home

unread,
Mar 24, 2003, 10:32:09 AM3/24/03
to

"Craig Powers" <eni...@hal-pc.org> wrote in message
news:3E7F2274...@hal-pc.org...

so if I use VB, I will need to somehow call invoke directly. I just thought
there might have been a way to call methods by their disp id's without
using invoke, but I gather there is no such thing.

Craig Powers

unread,
Mar 24, 2003, 12:06:52 PM3/24/03
to

In message <3E78B23F...@hal-pc.org>, I had a go at a quick way
to call Invoke in VB. Note the caveats - I'm not sure this is
actually possible. It might be necessary to produce some sort of
wrapper that would convert to VB-compatible argument types. Since
you're posting here in the ATL group, I wouldn't guess that would be
too much of an issue if it's necessary.

Jeff Kohn

unread,
Mar 25, 2003, 12:15:12 PM3/25/03
to
Why do you want to do this?

"Moody" <mo...@nospam.com> wrote in message
news:b5icl9$5oe$1...@titan.btinternet.com...

Brian Muth

unread,
Mar 25, 2003, 1:49:41 PM3/25/03
to
I was wondering the same thing! :-)


Alexander Nickolov

unread,
Mar 25, 2003, 5:59:06 PM3/25/03
to
You still type the name of the method in VB. The following conditions
must be true in order for DISPID binding (as it is officially called) to
work in VB:
- the interface must be pure dispinterface, not a dual interface - VB
will always favor the vtable portion of a dual interface because it's much
faster
- the dispinterface must be declared in a type library - so VB can map
the method names to their DISPIDs
- you must reference that type library in VB - see above
- you must declare your VB variable of a type interface (or a coclass,
which really implies the default interface for that coclass), not Object

If the above conditions are met, VB will use DISPID binding and call
through IDispatch::Invoke only, using the DISPIDs from the TLB.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"me@home" <ho...@nospam.com> wrote in message news:b5n8dp$6f6$1...@hercules.btinternet.com...

me@home

unread,
Mar 25, 2003, 7:20:37 PM3/25/03
to
I don't need this feature, I was simply wondering, I think because
I started to think in the direction of databases, where, I think, it
is possible to refer to fields by their position rather than their name,
so no reason really...

"Brian Muth" <bm...@straightthroughnospam.com> wrote in message
news:elRJM9v8...@TK2MSFTNGP11.phx.gbl...

0 new messages