Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Adding a new function to an old interface


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Jan 9, 2017 9:49 AM Last Post By: Remy Lebeau (Te...
Ed Dressel

Posts: 42
Registered: 10/10/99
Adding a new function to an old interface  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2017 3:09 PM
I don't do much with interfaces--but I have an interface with a GUID I have been using in my project for years. I now need to add another functions to the interface. Do I need to change the GUID?

Aside, the GUID is for working with COM (I am not sure exactly what that means) , but the only system call I make is supports(...). Is that a COM call?

Thanks

Ed Dressel

Edited by: Ed Dressel on Jan 7, 2017 3:10 PM
Alex Belo

Posts: 626
Registered: 10/8/06
Re: Adding a new function to an old interface [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2017 10:14 PM   in response to: Ed Dressel in response to: Ed Dressel
Ed Dressel wrote:

I don't do much with interfaces--but I have an interface with a GUID
I have been using in my project for years. I now need to add another
functions to the interface. Do I need to change the GUID?

What is the correct way to extend an existing ActiveX/COM component?
http://stackoverflow.com/questions/5191320/what-is-the-correct-way-to-extend-an-existing-activex-com-component

Properly extending a COM interface (IDL)
http://stackoverflow.com/questions/1867634/properly-extending-a-com-interface-idl

--
Alex
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Adding a new function to an old interface [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 8, 2017 11:26 PM   in response to: Ed Dressel in response to: Ed Dressel
Ed Dressel wrote:

I don't do much with interfaces--but I have an interface with a GUID
I have been using in my project for years. I now need to add another
functions to the interface. Do I need to change the GUID?

Aside, the GUID is for working with COM (I am not sure exactly what
that means) , but the only system call I make is supports(...). Is
that a COM call?

No. But it is generally a bad idea to change an interface. Just define
a MyInterfaceEx with the added method, and that must, of course, have a
new GUID.

--
Rudy Velthuis http://www.rvelthuis.de

"They said I was the greatest pitcher they ever saw; I couldn't
understand why they couldn't give me no justice."
-- Satchel Paige
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Adding a new function to an old interface [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 9, 2017 9:49 AM   in response to: Ed Dressel in response to: Ed Dressel
Ed wrote:

I don't do much with interfaces--but I have an interface with a GUID
I have been using in my project for years. I now need to add another
functions to the interface. Do I need to change the GUID?

Don't modify the existing interface at all. Derive a new interface from
the old interface, associate a new guid with the new interface, and add your
new functions to the new interface. Then you can update your existing implementation
class to implement the new interface. This way, you don't break any existing
code, and any new code can query the existing interface for the new interface
to call the new methods.

Aside, the GUID is for working with COM (I am not sure exactly what
that means)

All the more reason NOT to modify the existing interface. COM is very strict
about that.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02