📄 htkj.cpp
字号:
// HTKJ.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "HTKJ.h"
#include "HTKJDlg.h"
#include "LoginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHTKJApp
BEGIN_MESSAGE_MAP(CHTKJApp, CWinApp)
//{{AFX_MSG_MAP(CHTKJApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHTKJApp construction
CHTKJApp::CHTKJApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CHTKJApp object
CHTKJApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CHTKJApp initialization
BOOL CHTKJApp::InitInstance()
{
AfxEnableControlContainer();
m_BaseFlag=0;
LPCTSTR pFileName = _T(".\\HTLineSys.ini");
GetPrivateProfileString(_T("SERVER"),_T("source"),_T("127.0.0.1"),dbsrc.GetBuffer(128),128,pFileName);
dbsrc.ReleaseBuffer();
GetPrivateProfileString(_T("SERVER"),_T("dbname"),_T("HTPingJia"),dbname.GetBuffer(128),128,pFileName);
dbname.ReleaseBuffer();
GetPrivateProfileString(_T("SERVER"),_T("username"),_T("sa"),user.GetBuffer(128),128,pFileName);
user.ReleaseBuffer();
GetPrivateProfileString(_T("SERVER"),_T("password"),_T(""),pass.GetBuffer(128),128,pFileName);
pass.ReleaseBuffer();
strConnect = _T("Provider=SQLOLEDB.1; Data Source=") + dbsrc +
_T("; Initial Catalog=") + dbname +
_T("; User ID=") + user +
_T("; PWD=") + pass;
CoInitialize(NULL);
HRESULT hr;
AdoConnection.CreateInstance(_uuidof(Connection));
AdoRecordset.CreateInstance(_uuidof(Recordset));
try
{
hr=AdoConnection->Open(_bstr_t(LPCTSTR(strConnect)), "", "", -1);
}
catch (_com_error e)
{
TRACE(_T("Warning: 连接数据库发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
return FALSE;
}
catch (...)
{
TRACE(_T("Warning: 连接数据库时发生未知错误:"));
return FALSE;
}
int i;
CLoginDlg logDlg;
i=logDlg.DoModal();
if(i==2)
{return FALSE;}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CHTKJDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
int CHTKJApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
CoUninitialize();
AdoConnection->Close();
AdoConnection.Release();
AdoRecordset.Release();
return CWinApp::ExitInstance();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -