I wrote an API in C# which included a couple of overloaded methods:
bool SendMessage(byte[] msg);
bool SendMessage(byte[] msg, uint priority);
I've now been asked to add a COM wrapper. However COM doesn't
support overloads. Hence, my MIDL becomes:
[id(0x60020002)]
HRESULT SendMessage(
[in] SAFEARRAY(unsigned char) msg,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020003),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, SendMessage)]
HRESULT SendMessage_2(
[in] SAFEARRAY(unsigned char) msg,
[in] unsigned long priority,
[out, retval] VARIANT_BOOL* pRetVal);
Is there anyway around this? I don't want the application developers to have
to
write:
hr = pIsmf->SendMessage(psa, &bResult);
hr = pIsmf->SendMessage_2(psa, 1, &bResult);
Thanks folks.
Mattias Sj?gren - 09 Dec 2004 23:04 GMT
>Is there anyway around this?
No, COM doesn't support overloading.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Frederic Pesquet - 22 Dec 2004 10:35 GMT
> No, COM doesn't support overloading.
Ok, but is it possible to customize the generated COM name for the
overloaded methods ?
(i.e. renaming the second overloaded method with something like
SendMessageWithPriority)
I found no attributes to do so.
Thanks
Mattias Sj?gren - 05 Jan 2005 22:18 GMT
>Ok, but is it possible to customize the generated COM name for the
>overloaded methods ?
No easy way. But you can decompile the typelib with Oleview, edit it
as needed and then generate a new with MIDL.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.