Reputation: 56779
I want to do a simple performance experiment of using DAO with C++. I found this - https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/cc811599(v=office.12)?redirectedfrom=MSDN - which seems to indicate I could do something like:
#import <C:\Program Files\Common Files\microsoft shared\OFFICE14\ACEDAO.DLL> rename( "EOF", "AdoNSEOF" )
_bstr_t bstrConnect = "C:\\temp\\test.accdb";
DAO::_DBEngine* pEngine = NULL;
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(
__uuidof(DAO::DBEngine),
NULL,
CLSCTX_INPROC_SERVER,
IID_IDispatch,
(LPVOID*)&pEngine);
if (SUCCEEDED(hr) && pEngine)
{
// COM errors are handled by the C++ try/catch block.
try
{
DAO::DatabasePtr pDbPtr = NULL;
pDbPtr = pEngine->OpenDatabase(bstrConnect);
...
However it is failing on the call to OpenDatabase
with this error:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
I am admittedly over my head at this point - I did one semester of c++ decades ago. Research seems to indicate this is a problem with the header files - but I didn't make any header files, Visual Studio auto-created them by simply doing a build with the #import
line in place. Is it still possible to get something like this to work?
Upvotes: 0
Views: 42