Hey everyone,
I'm writing a DLL, and before I get too deep into the project, I'd like to have a few questions answered.
My DLL will let users retrieve recordsets and execute SQL commands to an Access database using the CDaoDatabase functionality of C++.
It keeps telling me
Quote: "'db' : undeclared identifier"
when I execute the following code...
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
#define MYCOMMAND __declspec(dllexport)
MYCOMMAND bool DBOpenDatabase(LPSTR pDBName)
{
CDaoDatabase db;
db.Open(pDBName);
if(db.IsOpen()) return true;
else return false;
}
This is obviously because I need the header file in there for CDaoDatabase (afxdao.h), so when I add it to the top of the code, I still get the same error. If I move the #include <afxdao.h> *below* the #include "stdafx.h", then it says
Quote: "WINDOWS.H already included. MFC apps must not #include <windows.h>"
*THEN*, I went into the StdAfx.h header file in my project, commented out #include <windows.h> just to see what would happen, and all hell broke loose:
Quote: "nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in DBACCESS2.obj
nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in DBACCESS2.obj; second definition ignored
Creating library Debug/DBACCESS2.lib and object Debug/DBACCESS2.exp
Debug/DBACCESS2.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe."
Can anyone see what I'm doing wrong? I've about had it up to the ceiling with this trouble! If you have any more questions of me, please ask.
I've made DLLs before, and I know how to get them compiled properly, etc.
Thanks
Ancient Chinese proverb: Man who runs behind car gets exhausted.

http://www.automatongames.com/