fatal error LNK1561: 必须定义入口点

时间:2022-09-07 13:22:07
#include "stdafx.h"
#include "Land.h"
#include "LandDlg.h"

BEGIN_MESSAGE_MAP(CLandApp,CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

CLandApp::CLandApp()
{

}

CLandApp  theApp;

BOOL CLandApp::InitInstance()
{
AfxEnableControlContainer();

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

CLandDlg 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;
}

7 个解决方案

#1


// LandDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "Land.h"
#include "LandDlg.h"
#include "afxdialogex.h"


// CLandDlg 对话框

IMPLEMENT_DYNAMIC(CLandDlg, CDialogEx)

CLandDlg::CLandDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CLandDlg::IDD, pParent)
{

EnableAutomation();

}

CLandDlg::~CLandDlg()
{
}

void CLandDlg::OnFinalRelease()
{
// 释放了对自动化对象的最后一个引用后,将调用
// OnFinalRelease。基类将自动
// 删除该对象。在调用该基类之前,请添加您的
// 对象所需的附加清理代码。

CDialogEx::OnFinalRelease();
}

void CLandDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CLandDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnBtnOk)
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CLandDlg, CDialogEx)
END_DISPATCH_MAP()

BOOL CLandDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon,TRUE);
SetIcon(m_hIcon,FALSE);

return TRUE;
}

void CLandDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}

}
HCURSOR CLandDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CLandDlg::OnBtnOk()
{
UpdateData(TRUE);
int iRet = OnLogin(m_pUserName,m_pPass);
if(iRet == -1)
{
MessageBox("数据库并不存在");
}
else if(iRet == 0)
{
MessageBox("错误的用户名或密码");
}
else if(iRet == 1)
{
MessageBox("登陆成功");
}
else if(iRet > 1)
{
MessageBox("用重名用户");
}
}
BOOL CLandDlg::AdoInit()
{
if(!AfxOleInit())
{
MessageBox("OLE初始化失败");
return FALSE;
}
memset(m_pConnectString,0x0,sizeof(m_pConnectString));
memset(m_pProgPath,0x0,sizeof(m_pProgPath));
GetCurrentDirectory(256,m_pProgPath);                           //获得程序路径
m_pProgPath[strlen(m_pProgPath)]='\\';
strcpy(m_pConnect,"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=");
strcpy(m_pDBName,"Exam.mdb");
strcat(m_pConnectString,m_pConnect);
strcat(m_pConnectString,m_pProgPath);
strcat(m_pConnectString,m_pDBName);
return TRUE;
}

int CLandDlg::OnLogin(CString username,CString pass)
{/*
if (FAILED(m_pRst.CreateInstance("ADODB.Recordset")))
{
MessageBox("Create Instance failed!");
return FALSE;
}

int i = 0;
CString sql = "select 1 from user_t where UserName='"+userName+"' and Password='"+pass+"'";
if(FAILED(m_pRst->Open((_variant_t)sql,(_variant_t)m_pConnectString,adOpenStatic,adLockOptimistic,adCmdText)))
{
m_pRst.Release();
return -1;
}
while(!m_pRst->GetadoEOF())
{
i++;
m_pRst->MoveNext();

}
m_pRst.Release();*/
return 0;
}


// 注意: 我们添加 IID_ILandDlg 支持
//  以支持来自 VBA 的类型安全绑定。此 IID 必须同附加到 .IDL 文件中的
//  调度接口的 GUID 匹配。

// {ECBF284B-2EBD-42FC-BCA8-1B5C3C54787B}
static const IID IID_ILandDlg =
{ 0xECBF284B, 0x2EBD, 0x42FC, { 0xBC, 0xA8, 0x1B, 0x5C, 0x3C, 0x54, 0x78, 0x7B } };

BEGIN_INTERFACE_MAP(CLandDlg, CDialogEx)
INTERFACE_PART(CLandDlg, IID_ILandDlg, Dispatch)
END_INTERFACE_MAP()


// CLandDlg 消息处理程序

#2


WinMain
_tmain
main

#3


引用 2 楼 zhao4zhong1 的回复:
WinMain
_tmain
main

theApp不行么?

#4


引用 3 楼 huairui008 的回复:
Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?


引用 3 楼 huairui008 的回复:
Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?

C/C++只承认跟main有关的才是入口函数,其他都不行

#5


引用 4 楼 Adol1111 的回复:
Quote: 引用 3 楼 huairui008 的回复:

Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?


引用 3 楼 huairui008 的回复:
Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?

C/C++只承认跟main有关的才是入口函数,其他都不行

那我这个该怎么改?

#6


是自己写的吗,还是向导自动生成的框架?
我记得mfc中initapp之类的函数是在winmain中调用的。
不然就直接用向导自动生成框架,再往里填

#7


引用 6 楼 lpcads 的回复:
是自己写的吗,还是向导自动生成的框架?
我记得mfc中initapp之类的函数是在winmain中调用的。
不然就直接用向导自动生成框架,再往里填

自己写的,问题解决了~在项目属性里设置下就OK了

#1


// LandDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "Land.h"
#include "LandDlg.h"
#include "afxdialogex.h"


// CLandDlg 对话框

IMPLEMENT_DYNAMIC(CLandDlg, CDialogEx)

CLandDlg::CLandDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CLandDlg::IDD, pParent)
{

EnableAutomation();

}

CLandDlg::~CLandDlg()
{
}

void CLandDlg::OnFinalRelease()
{
// 释放了对自动化对象的最后一个引用后,将调用
// OnFinalRelease。基类将自动
// 删除该对象。在调用该基类之前,请添加您的
// 对象所需的附加清理代码。

CDialogEx::OnFinalRelease();
}

void CLandDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CLandDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnBtnOk)
END_MESSAGE_MAP()

BEGIN_DISPATCH_MAP(CLandDlg, CDialogEx)
END_DISPATCH_MAP()

BOOL CLandDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon,TRUE);
SetIcon(m_hIcon,FALSE);

return TRUE;
}

void CLandDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}

}
HCURSOR CLandDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CLandDlg::OnBtnOk()
{
UpdateData(TRUE);
int iRet = OnLogin(m_pUserName,m_pPass);
if(iRet == -1)
{
MessageBox("数据库并不存在");
}
else if(iRet == 0)
{
MessageBox("错误的用户名或密码");
}
else if(iRet == 1)
{
MessageBox("登陆成功");
}
else if(iRet > 1)
{
MessageBox("用重名用户");
}
}
BOOL CLandDlg::AdoInit()
{
if(!AfxOleInit())
{
MessageBox("OLE初始化失败");
return FALSE;
}
memset(m_pConnectString,0x0,sizeof(m_pConnectString));
memset(m_pProgPath,0x0,sizeof(m_pProgPath));
GetCurrentDirectory(256,m_pProgPath);                           //获得程序路径
m_pProgPath[strlen(m_pProgPath)]='\\';
strcpy(m_pConnect,"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=");
strcpy(m_pDBName,"Exam.mdb");
strcat(m_pConnectString,m_pConnect);
strcat(m_pConnectString,m_pProgPath);
strcat(m_pConnectString,m_pDBName);
return TRUE;
}

int CLandDlg::OnLogin(CString username,CString pass)
{/*
if (FAILED(m_pRst.CreateInstance("ADODB.Recordset")))
{
MessageBox("Create Instance failed!");
return FALSE;
}

int i = 0;
CString sql = "select 1 from user_t where UserName='"+userName+"' and Password='"+pass+"'";
if(FAILED(m_pRst->Open((_variant_t)sql,(_variant_t)m_pConnectString,adOpenStatic,adLockOptimistic,adCmdText)))
{
m_pRst.Release();
return -1;
}
while(!m_pRst->GetadoEOF())
{
i++;
m_pRst->MoveNext();

}
m_pRst.Release();*/
return 0;
}


// 注意: 我们添加 IID_ILandDlg 支持
//  以支持来自 VBA 的类型安全绑定。此 IID 必须同附加到 .IDL 文件中的
//  调度接口的 GUID 匹配。

// {ECBF284B-2EBD-42FC-BCA8-1B5C3C54787B}
static const IID IID_ILandDlg =
{ 0xECBF284B, 0x2EBD, 0x42FC, { 0xBC, 0xA8, 0x1B, 0x5C, 0x3C, 0x54, 0x78, 0x7B } };

BEGIN_INTERFACE_MAP(CLandDlg, CDialogEx)
INTERFACE_PART(CLandDlg, IID_ILandDlg, Dispatch)
END_INTERFACE_MAP()


// CLandDlg 消息处理程序

#2


WinMain
_tmain
main

#3


引用 2 楼 zhao4zhong1 的回复:
WinMain
_tmain
main

theApp不行么?

#4


引用 3 楼 huairui008 的回复:
Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?


引用 3 楼 huairui008 的回复:
Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?

C/C++只承认跟main有关的才是入口函数,其他都不行

#5


引用 4 楼 Adol1111 的回复:
Quote: 引用 3 楼 huairui008 的回复:

Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?


引用 3 楼 huairui008 的回复:
Quote: 引用 2 楼 zhao4zhong1 的回复:

WinMain
_tmain
main

theApp不行么?

C/C++只承认跟main有关的才是入口函数,其他都不行

那我这个该怎么改?

#6


是自己写的吗,还是向导自动生成的框架?
我记得mfc中initapp之类的函数是在winmain中调用的。
不然就直接用向导自动生成框架,再往里填

#7


引用 6 楼 lpcads 的回复:
是自己写的吗,还是向导自动生成的框架?
我记得mfc中initapp之类的函数是在winmain中调用的。
不然就直接用向导自动生成框架,再往里填

自己写的,问题解决了~在项目属性里设置下就OK了