📄 avinfokernel.cpp
字号:
// AVInfoKernel.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "AVInfoKernel.h"
#include "AVInfoAPIExtension.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
/////////////////////////////////////////////////////////////////////////////
// CAVInfoKernelApp
extern HMODULE g_hExtensionModule;
extern LPInitInfoExtension g_fpInitInfoExtension;
extern LPExitInfoExtension g_fpExitInfoExtension;
extern LPSetPropData g_fpSetPropData;
extern LPSetPropDataAuto g_fpSetPropDataAuto;
extern LPCopyPropData g_fpCopyPropData;
extern LPCopyEvent g_fpCopyEvent;
extern LPGetPropData g_fpGetPropData;
extern LPRemovePropData g_fpRemovePropData;
extern LPDeletePropData g_fpDeletePropData;
extern LPOpenModel g_fpOpenModel;
extern LPSetModel g_fpSetModel;
extern LPCopyModel g_fpCopyModel;
extern LPSaveModel g_fpSaveModel;
extern LPCloseModel g_fpCloseModel;
BEGIN_MESSAGE_MAP(CAVInfoKernelApp, CWinApp)
//{{AFX_MSG_MAP(CAVInfoKernelApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAVInfoKernelApp construction
CAVInfoKernelApp::CAVInfoKernelApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_strModelName = _T("");
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CAVInfoKernelApp object
CAVInfoKernelApp theApp;
BOOL CAVInfoKernelApp::InitInstance()
{
//首先装载应用系统扩展模块,并获取其中的属性数据操作接口函数地址以备调用
g_hExtensionModule = ::LoadLibrary("INFOExtension.dll");
if(g_hExtensionModule)
{
g_fpInitInfoExtension = (LPInitInfoExtension)::GetProcAddress(g_hExtensionModule,"InitInfoExtension");
g_fpExitInfoExtension = (LPExitInfoExtension)::GetProcAddress(g_hExtensionModule,"ExitInfoExtension");
g_fpSetPropData = (LPSetPropData)::GetProcAddress(g_hExtensionModule,"SetPropData");
g_fpSetPropDataAuto = (LPSetPropDataAuto)::GetProcAddress(g_hExtensionModule,"SetPropDataAuto");
g_fpCopyPropData = (LPCopyPropData)::GetProcAddress(g_hExtensionModule,"CopyPropData");
g_fpCopyEvent = (LPCopyEvent)::GetProcAddress(g_hExtensionModule,"CopyEvent");
g_fpGetPropData = (LPGetPropData)::GetProcAddress(g_hExtensionModule,"GetPropData");
g_fpRemovePropData = (LPRemovePropData)::GetProcAddress(g_hExtensionModule,"RemovePropData");
g_fpDeletePropData = (LPDeletePropData)::GetProcAddress(g_hExtensionModule,"DeletePropData");
g_fpOpenModel = (LPOpenModel)::GetProcAddress(g_hExtensionModule,"OpenModel");
g_fpSetModel = (LPSetModel)::GetProcAddress(g_hExtensionModule,"SetModel");
g_fpCopyModel = (LPCopyModel)::GetProcAddress(g_hExtensionModule,"CopyModel");
g_fpSaveModel = (LPSaveModel)::GetProcAddress(g_hExtensionModule,"SaveModel");
g_fpCloseModel = (LPCloseModel)::GetProcAddress(g_hExtensionModule,"CloseModel");
}
return CWinApp::InitInstance();
}
BOOL CAVInfoKernelApp::Init()
{
BOOL bConnected = TRUE;
char szDSN[128];
CString str;
::AVGetPropDataSource(szDSN);
str = szDSN;
//wxg20050622 实体类向导不显示类型(数据库连接的问题)
BOOL bNet = ::GetPrivateProfileInt("network","network",0,"..\\Data\\AutoTicket.ini");
if(!bNet)
str = str+";UID=;PWD=bj62962288XC";
strcpy(szDSN,str.GetBuffer(str.GetLength()));
str.ReleaseBuffer();
m_pDatabase = new CDatabase;
TRY
{
m_pDatabase->OpenEx(szDSN,CDatabase::noOdbcDialog);
}
CATCH(CDBException,e)
{
::AVWriteLog(_T("%s"),e->m_strError);
bConnected = FALSE;
}
END_CATCH
m_pTypeSet = NULL;
if(bConnected)
m_pTypeSet = new CRecordset(m_pDatabase);
return TRUE;
}
void CAVInfoKernelApp::Exit()
{
if(m_pTypeSet && m_pTypeSet->IsOpen())
m_pTypeSet->Close();
if(m_pDatabase->IsOpen())
m_pDatabase->Close();
delete m_pTypeSet;
delete m_pDatabase;
}
AV_EXPORT USHORT AVInitInfoExtension()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
theApp.Init();
return AV_NO_ERR;
}
AV_EXPORT USHORT AVExitInfoExtension()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
theApp.Exit();
return AV_NO_ERR;
}
int CAVInfoKernelApp::ExitInstance()
{
if(g_hExtensionModule)
::FreeLibrary(g_hExtensionModule);
return CWinApp::ExitInstance();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -