1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| AnsiString strGlobal;
class MyObject : public TObject
{
public:
void __fastcall MyOnStartup(System::TObject* _pSender)
{
strGlobal = "reached !";
}
};
void CParadoxDatabase::CheckDatabaseEngineStart()
{
AnsiString strFormat;
if (g_pDataModule == NULL)
{
m_strLastError += "module == NULL";
}
else
{
m_strLastError += "module != NULL";
}
if (!m_bInitDatabaseDone)
{ // Ask the operating system to allow up to 68 file handles (this is a
// Requirement of BDE)
int iHandlesWanted = 68;
int iHandlesAvailable = SetHandleCount(iHandlesWanted);
if (iHandlesAvailable < iHandlesWanted)
{
strFormat.printf("Cannot initialize database engine: cannot allow %d handles, only %d avalaible",iHandlesWanted,iHandlesAvailable);
m_strLastError += strFormat;
}
else
{
DBIResult dbiResult = DbiInit(NULL);
// initializing the driver
if (dbiResult != DBIERR_NONE)
{
strFormat.printf("Cannot initialize database engine: DbiInit failed (return error code: %d )!",(int) dbiResult);
m_strLastError += strFormat;
}
else
{
m_strLastError += "Bde Intalled !! -";
//TApplication *pApplication = new TApplication(NULL);
//TDataModule
MyObject *myO = new MyObject();
TSession *pMySession = new TSession(NULL);
pMySession->SessionName = "Session" + IntToStr(Sessions->Count);
pMySession->OnStartup = myO->MyOnStartup;
__try
{
pMySession->Open(); // raise EDBEngineError
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
m_strLastError.printf("-%s- Exception Code = %X",strGlobal.c_str(),GetExceptionCode());
return;
}
m_strLastError += "!!! OK !!!";
} |