Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ATL/COM Question

ATL/COM Question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comhelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bret Faller
    wrote on last edited by
    #1

    Hello, I am creating a COM DLL which is like the Outlook Object Model. I have an Application Interface/Coclass etc etc. My question is...how can I have two functions that do the same thing but have different calling methods depending on if you are using VB or VC++? Here's an example... if you look at the _Namespace interface in MSOUTL9.olb type library there is a function: HRESULT GetDefaultFolder([in] OlDefaultFolders FolderType, [out, retval] MAPIFolder** Folder); if you then look at the coclass Namespace it has a function: MAPIFolder* GetDefaultFolder([in] OlDefaultFolders FolderType); they both have the same id and helpstring but if you use VC++ you have to call the first one, and in VB the second (due to VB not using Interfaces and using coclasses instead) but how can I create a function like that? I can only create one function with that id or else VC++ complains. Any help is GREATLY appreciated. Bret Faller Odyssey Computing, Inc.

    N 1 Reply Last reply
    0
    • B Bret Faller

      Hello, I am creating a COM DLL which is like the Outlook Object Model. I have an Application Interface/Coclass etc etc. My question is...how can I have two functions that do the same thing but have different calling methods depending on if you are using VB or VC++? Here's an example... if you look at the _Namespace interface in MSOUTL9.olb type library there is a function: HRESULT GetDefaultFolder([in] OlDefaultFolders FolderType, [out, retval] MAPIFolder** Folder); if you then look at the coclass Namespace it has a function: MAPIFolder* GetDefaultFolder([in] OlDefaultFolders FolderType); they both have the same id and helpstring but if you use VC++ you have to call the first one, and in VB the second (due to VB not using Interfaces and using coclasses instead) but how can I create a function like that? I can only create one function with that id or else VC++ complains. Any help is GREATLY appreciated. Bret Faller Odyssey Computing, Inc.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      I think you are a little confused there is only one method here. As you said it is defined in the IDL as HRESULT GetDefaultFolder([in] OlDefaultFolders FolderType, [out, retval] MAPIFolder** Folder); However in the coclass it is MAPIFolder* GetDefaultFolder([in] OlDefaultFolders FolderType); VB uses it somthing like this Dim MFolder as MAPIFolder Set MFolder = GetDefaultFolder(...) On the other hand in C++ it is used such as MAPIFolder* pMFolder; HRESULT hr = GetDefaultFolder(... ,&pMFolder); The trick is the [out,retval] in the IDL definition. VB does not return HRESULT like C++ so this says that this parameter will be returned instead. The out part tells C++ that this parameter will be outgoing. Clear it up for you?

      B 1 Reply Last reply
      0
      • N Not Active

        I think you are a little confused there is only one method here. As you said it is defined in the IDL as HRESULT GetDefaultFolder([in] OlDefaultFolders FolderType, [out, retval] MAPIFolder** Folder); However in the coclass it is MAPIFolder* GetDefaultFolder([in] OlDefaultFolders FolderType); VB uses it somthing like this Dim MFolder as MAPIFolder Set MFolder = GetDefaultFolder(...) On the other hand in C++ it is used such as MAPIFolder* pMFolder; HRESULT hr = GetDefaultFolder(... ,&pMFolder); The trick is the [out,retval] in the IDL definition. VB does not return HRESULT like C++ so this says that this parameter will be returned instead. The out part tells C++ that this parameter will be outgoing. Clear it up for you?

        B Offline
        B Offline
        Bret Faller
        wrote on last edited by
        #3

        Very nice clarification. Thank you very much for your response. Bret Faller Odyssey Computing, Inc.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups