ATL/COM Question
-
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.
-
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.
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 isMAPIFolder* GetDefaultFolder([in] OlDefaultFolders FolderType);
VB uses it somthing like thisDim MFolder as MAPIFolder Set MFolder = GetDefaultFolder(...)
On the other hand in C++ it is used such asMAPIFolder* 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? -
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 isMAPIFolder* GetDefaultFolder([in] OlDefaultFolders FolderType);
VB uses it somthing like thisDim MFolder as MAPIFolder Set MFolder = GetDefaultFolder(...)
On the other hand in C++ it is used such asMAPIFolder* 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?Very nice clarification. Thank you very much for your response. Bret Faller Odyssey Computing, Inc.