📄 rcmssql.cpp
字号:
// RcMSSQL.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#include "RcMSSQL.h"
// Stardard headers
#include <afxtempl.h>
// Custom added
#include "RcOApplication.h"
#include "BrowseServersDlg.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.
//
HWND g_hWnd=NULL;
UINT g_uSyn=0;
CRcOApplication* g_pRcOApplication;
CBrowseServersDlg* g_pBrowseServersDlg;
/////////////////////////////////////////////////////////////////////////////
// CRcMSSQLApp
BEGIN_MESSAGE_MAP(CRcMSSQLApp, CWinApp)
//{{AFX_MSG_MAP(CRcMSSQLApp)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CRcMSSQLApp construction
CRcMSSQLApp::CRcMSSQLApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CRcMSSQLApp object
CRcMSSQLApp theApp;
BOOL CRcMSSQLApp::InitInstance()
{
g_hWnd = NULL;
g_pRcOApplication = NULL;
if (g_pRcOApplication == NULL) g_pRcOApplication=new CRcOApplication;
g_pBrowseServersDlg = NULL;
if (g_pBrowseServersDlg == NULL) g_pBrowseServersDlg=new CBrowseServersDlg;
return CWinApp::InitInstance();
}
int CRcMSSQLApp::ExitInstance()
{
if (g_pRcOApplication != NULL)
{
delete g_pRcOApplication;
g_pRcOApplication = NULL;
}
if (g_pBrowseServersDlg != NULL)
{
delete g_pBrowseServersDlg;
g_pBrowseServersDlg = NULL;
}
return CWinApp::ExitInstance();
}
//////////////////////////////////////////////////////////////////////////////////////
// custom added
extern "C" __declspec(dllexport) BOOL DllInitializtion(HWND hWnd)
{
g_hWnd = hWnd;
if (!g_pRcOApplication->Initializtion())
{
MessageBox(g_hWnd, g_pRcOApplication->GetErrorMessage(), "信息...", MB_OK);
return FALSE;
}
if (!g_pRcOApplication->SetAvailableServersList())
{
MessageBox(g_hWnd, g_pRcOApplication->GetErrorMessage(), "信息...", MB_OK);
return FALSE;
}
return TRUE;
}
extern "C" __declspec(dllexport) BOOL DllCompletion()
{
if (!g_pRcOApplication->Completion())
{
MessageBox(g_hWnd, g_pRcOApplication->GetErrorMessage(), "信息...", MB_OK);
return FALSE;
}
return TRUE;
}
extern "C" __declspec(dllexport) LPCTSTR GetErrorMessage()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pRcOApplication->GetErrorMessage();
}
extern "C" __declspec(dllexport) CArray<CString,CString&>* AGetServersList()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pRcOApplication->GetAvailableServersList();
}
extern "C" __declspec(dllexport) LONG AGetServersAmount()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pRcOApplication->GetAvailableServersAmount();
}
/*
extern "C" __declspec(dllexport) CArray<CString,CString&>* EnumInstalledInstance()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (g_pEnumInstance == NULL) g_pEnumInstance = new CRcOApplication;
if (!g_pEnumInstance->SetInstalledInstanceList())
{
AfxMessageBox(g_pEnumInstance->GetErrorMessage());
}
return g_pEnumInstance->GetInstalledInstanceList();
}
extern "C" __declspec(dllexport) CArray<CString,CString&>* GetInstalledInstanceName()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pEnumInstance->GetInstalledInstanceList();
}
extern "C" __declspec(dllexport) long GetInstalledInstanceAmount()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return g_pEnumInstance->GetInstalledInstanceAmount();
}
*/
extern "C" __declspec(dllexport) LPCTSTR WBrowseServersDoModal()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (!g_pRcOApplication->SetAvailableServersList())
{
MessageBox(g_hWnd, g_pRcOApplication->GetErrorMessage(), "信息...", MB_OK);
return NULL;
}
CArray<CString,CString&> *parrServersList;
parrServersList=g_pRcOApplication->GetAvailableServersList();
g_pBrowseServersDlg->SetServersList(parrServersList);
if (g_pBrowseServersDlg->DoModal() == IDOK)
{
return (LPCTSTR) g_pBrowseServersDlg->GetServerName();
}
}
extern "C" __declspec(dllexport) LPCTSTR WGetServerName()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return (LPCTSTR) g_pBrowseServersDlg->GetServerName();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -