| Home Forum RSS PGP Alerts Links (B) |
|
|
|
|
(Note: also check out Kim Nevelsteen's notes on IDL) msado15 treatment in the IDL Comment on this articleIf you use msado15 definitions in one component and want to use that component in another component that also independently needs to use msado15, you're in for an interesting experience. A typical example would be that you have one COM dll connecting to a database and constructing recordsets while your second COM dll gets the recordsets from the first and proceeds to do something with them. Naturally, both the first and the second COM dll need to import the ADO definitions of recordsets in several places. After much back-and-forth, I think I've got this working by including and importing as follows. First COM DLLThis one only utilizes ADO and is, in turn, used by the second COM DLL. The important lines are marked in red.
#import "\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF", "adoEOF")
Here's an excerpt from the IDL file: // QcDAL.idl : IDL source for QcDAL.dll
//
import "oaidl.idl";
import "ocidl.idl";
/////////////////////////////////////////////////////////////////////////////
// forward declarations we may need
/////////////////////////////////////////////////////////////////////////////
cpp_quote("struct _Connection;")
[
uuid(AF86A5F1-2CBD-11D4-AC30-00A0244EB971),
version(1.0),
helpstring("QcDAL 1.0 Type Library")
]
library QCDALLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
importlib("/program files/common files/system/ado/msado15.dll");
interface IDbConnection;
[
object,
uuid(AF86A5FE-2CBD-11D4-AC30-00A0244EB971),
dual,
helpstring("IContext Interface"),
pointer_default(unique)
]
interface IContext : IDispatch
{
[id(3), helpstring("method GetADOConnPtr")]
HRESULT GetADOConnPtr(
[out, retval] _Connection** ppConnection);
};
.
.
.
Second COM DLLThis is the one that utilizes both the first COM DLL and ADO. cpp_quote("struct _Connection;")
cpp_quote("struct IDAL;")
// ------------------------------------------------------------------------- //
[
uuid(FFCBC525-5733-4B10-80A2-8C63079DF082),
version(1.0),
helpstring("QSE 1.0 Type Library")
]
library QSELib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
importlib("/program files/common files/system/ado/msado15.dll");
import "/projects/c3/objects/qcdal/qcdal.idl";
.
.
Note that you again need to do the importlib of ADO. After that, you do the regular import of the first COM idl file. Now, wherever you need to use the first COM in you second COM dll, you need to import the msado15.dll before importing the first COM dll, since none of the msado types are in the first COM typelibrary. So, a typical .cpp (or possibly header) in the second COM dll would contain the lines: .
.
#import "/program files/common files/system/ado/msado15.dll" no_namespace rename("EOF", "adoEOF")
#import "/projects/c3/objects/qcdal/qcdal.dll" no_namespace
Ok, this should fix it. Have fun! |
|
| TOP |